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

    label: Category
    type: checkboxes
      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:

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

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


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