We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28436
    • 242 Posts
    Hello guys!

    I want to list a folder and its subfolders recursively.

    Initiate
    [[Ditto?parents=`162`&tpl=`list_recursive`&display=`all`&sortDir=`ASC`]]

    {{list_recursive}}
    [+id:hasChilds:is=`1`:then=`{{list_recursive_folder}}`:else=`{{list_recursive_element}}`+]

    {{list_recursive_folder}}
    <div class="wrapperCategorie">
        <h2 class="level[+id:level+]">[+pagetitle+]</h2>
        [[Ditto?parents=`[+id+]`&tpl=`list_recursive`&display=`all`&sortDir=`ASC`]]
    </div>

    {{list_recursive_element}}
    <div class="wrapperElement">
        [+pagetitle+]
    </div>
    This and exactly this work really fine.

    But if i want to use more placeholders in {{list_recursive_element}} they wont display. just [+id+] and [+pagetitle+] work....

    for example {{list_recursive_element}}
    <div class="wrapperElement">
        [+id+][+pagetitle+][+longtitle+][+introtext+]
    </div>
    display just the id and pagetitle

    Thats the strange behavior.
    if i use in the chunk "list_recursive" the source of the chunk {{list_recursive_element}} instead its call it will work.
    example
    [+id:hasChilds:is=`1`:then=`{{list_recursive_folder}}`:else=`
    <div class="wrapperElement">
        [+id+][+pagetitle+][+longtitle+][+introtext+]
    </div>
    `+]


    All fields are displayed.
    is it understandable what i want do do and write? And Is there a explanation for this?

    Thank you
    ciao, Stefan
      • 11975
      • 2,542 Posts
      Hi,

      you should activate the debug mode and check if the placeholders are properly found.
      They should appear in the fields tab.

      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 28436
        • 242 Posts
        Hi Helitrope,

        yes you are right, they _don’t_ appear in the fieldliste smiley

        display > db> id, published, pagetitle
        backend > db > id, published

        And is this noticeable? found in the "template"-tab
         	[+id:hasChilds:is=`1`:then=`{{list_recursive_folder}}`:else=`{ 23;list_recursive_element}}`+]
        23? instead a bracket?

        if i debug the second way( the chunk source instead {{list_recursive_element}} in {{list_recursive}} ) all parameters an placeholders are loaded.

        OK, thats fine. The facts are stable. But... what i have to do with this information? How to figure out what goes on with it?

        Thank you
        Stefan
          • 5197
          • 2 Posts
          hi stefan,

          your solution looks interesting.
          I tried it to implement it, but without success.

          I searched this forum several times.

          what is "hasChilds"?

          Thank you for your help.

          regards
          Chris
            • 28436
            • 242 Posts
            Hi Chris,

            hasChilds is a phx modifer. phx is a plugin for conditional templating. http://wiki.modxcms.com/index.php/PHx

            assets/plugins/phx/modifier/hasChilds.phx.php
            <?php
            if( count( $modx->getActiveChildren( (int)$output ) ) > 0 )
            {
                return '1';
            }
            else
            {
                return false;
            }
            ?>
            


            adios, Stefan
              • 5197
              • 2 Posts
              Hi Stefan,

              great. It works!

              Wunderful. Many thanx for your answer!

              I love modxcms!

              bye
              chris