Categories design

Hello,
since I have only recently started working with Kirby CMS and have little experience in php, I wanted to inquire whether it is possible to use checkboxes for categories.
Also I would then each check box a different color. Is that possible

Thanks in advance
Greeting
tomix

Checkboxes can be used for categories. See here.

You can probably color them with a panel stylesheet.

Thanks for your quick reply. I think I was wrong, I wanted to edit the categories / checkboxes not in the panel / backend with CSS but in the front end / on the website.

Greeting
Tom

Sure, but thats not something Kirby does, style is up to you via CSS. Depending on what you want, it can easy or hard to do this because checkboxes are not very style friendly. I usually hide the checkbox and style the label instead to look like a checkbox. This works because clicking on a label activates the checkbox associated with it.

OK thanks. but how could I realize it

Well, something like this. It sounds like what you are trying to create is a category filter…i’m guessing what you want to happen is for the posts to be organised on the page according to the ticked boxes? For that you will need to fetch the posts with Ajax and use javascript to filter it.

In the principle, it should look in the source code so

  • CategoryName1
  • category name2 so i can edit it via css in frontend.

    gruss tomix

  • It is probably better to use tags in your articles to organise them.

    You can use pluck to display them.

    something like…

    <?php $tags = $pages->children()->pluck('tags', ',', true); ?>
    <ul class="catlist">
    <?php foreach ($tags as $tag): ?>
      <li class="cat-item">  <label for="<?php echo html($tag) ?>"><?php echo html($tag) ?></label> <input name="<?php echo html($tag) ?>" id="<?php echo html($tag) ?>" type="checkbox"/> </li>
    <?php endforeach ?>
    </ul>
    

    The checkboxes have ID’s now, so you can style them.

    `indent preformatted text by 4 spaces`
    

    many many thanks that was exactly what I was looking for

    No worries. You can add tags to an article by using the tag field in your blueprints. Full list of fields here.