Categories only displaying first word?

Hi! I’m pretty new to php/programming so this is probably basic but here goes…

I want each project page of mine to display the roles (“Categories”) they sit in.

I added this to my project.yml

  category:
    label: Category
    type: checkboxes
    options:
      art direction: Art direction
      branding: Branding
      illustration: Illustration
      publication: Publication
      print: Print
      web design: Web design

And I’m using this code to output each category:

<h4>
 <?php echo implode(', ',  array_map('ucfirst', $page->categories()->split(','))) ?>.
</h4>

But “Art direction” and “Web design” only show up as “Art” and “Web”. Am I using the correct variables? When I did a var dump on $page->categories() it came up with

Thanks!

Just did a quick test and it seems to be working for me (Kirby 2.4.1). Which version of Kirby are you using?

Ah yikes, I think it was because I had renamed “Categories” to “Category” in the yml file? Did some reworking directly in the .txt files and now its working! Realised after you said it worked for you!

Cheers haha

Haha, yes :slight_smile:
I only copy-pasted the blueprint and did the output by hand - with category.

Happy Coding

1 Like