Posts by hus_hmd

    Hello dazglaser


    You can expand your original solution for the 2 levels and make it more dynamic to handle any number of levels:



    Note I'm using a function get_sub_categories() inside the each option. This allows you to handle things more dynamically. If you really need separate templates:



    If you only need to apply a different CSS class based on the level, you can remove the first bit of the function and rely on conditional tags inside the template:




    All your templates would need to have the following to display the subitems:


    HTML
    1. <perch:category id="subitems" html>

    A while ago I wrote a field type which can be used to select Collection keys. Just published it on GitHub now: https://github.com/Pipits/collection-fieldtype


    Template:


    HTML
    1. <perch:content id="collections" type="collection" label="Collections">


    PHP:


    PHP
    1. $collection_keys = perch_content('Collections', true);
    2. $collection_keys = explode(',', $collection_keys);
    3. foreach($collection_keys as $collection_key) {
    4. perch_collection($collection_key, ['template' => 'card.html']);
    5. }

    Hello dosa,


    Do you need to display a single Collection on the page and give the editor control over which one gets displayed?


    Or do you need to display multiple Collections on the page and give the editor control over which ones get displayed?