We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8427
    • 14 Posts
    Hi all.

    I need to obtain a structure similar to following one:
    <ul>
      <li class="first">
         <h2>Title1</h2>
         <ul>
             <li class="first">
                <h3>Title2</h3>
                <a href="mypage.php"><img src="myimage1.jpg" alt="Title" /></a>
             </li>
             <li>
                <h3>Title3</h3>
                <a href="mypage.php"><img src="myimage2.jpg" alt="Title" /></a>
             </li>
             <li>
                <h3>Title4</h3>
                <a href="mypage.php"><img src="myimage3.jpg" alt="Title" /></a>
             </li>
         </ul>
      </li>
      <li>
         <h2>Title5</h2>
         <ul>
             <li class="first">
                <h3>Title6</h3>
                <a href="mypage.php"><img src="myimage4.jpg" alt="Title" /></a>
             </li>
             <li>
                <h3>Title7</h3>
                <a href="mypage.php"><img src="myimage5.jpg" alt="Title" /></a>
             </li>
             <li>
                <h3>Title8</h3>
                <a href="mypage.php"><img src="myimage6.jpg" alt="Title" /></a>
             </li>
         </ul>
      </li>
    </ul>
    


    So, I’ve create a chunk with the first getResource:
    <ul>[[!getResources? &parents=`4` &tpl=`ul-li-tpl` &tplFirst=`ul-li-first-tpl` &showHidden=`true` &depth=`1` &sortby=`id`]]</ul>


    then the templates:
    <!-- ul-li-tpl -->
    <li>
       <h2>[[+pagetitle]]</h2>
       <ul>
         [[$chunk2 &idd=[[+id]]]]
       </ul>                
    </li>
    

    <!-- ul-li-first-tpl -->
    <li class="first">
       <h2>[[+pagetitle]]</h2>
       <ul>
         [[$chunk2 &idd=[[+id]]]]
       </ul>                
    </li>
    


    then the secondo chunk ($chunk2) with the second getResource:
    <!-- chunk2 -->
    [[!getResources? &parents=`[[+idd]]` &tpl=`ul-li-ul-li-tpl` &tplFirst=`ul-li-ul-li-first-tpl` &includeTVs=`1` &showHidden=`true`]]
    


    and the 2 templates:
    <!-- ul-li-ul-li-tpl -->
    <li><h3>[[+pagetitle]]</h3><a href="[[~[[+id]]]]"><img src="[[+myimg]]" alt="[[+pagetitle]]" /></a></li>
    

    <!-- ul-li-ul-li-first-tpl -->
    <li class="first"><h3>[[+pagetitle]]</h3><a href="[[~[[+id]]]]"><img src="[[+myimg]]" alt="[[+pagetitle]]" /></a></li>
    



    But I didn’t achieve what I was expecting:
    <ul>
       <li class="first">
          <h2>Title</h2>
          <ul>
         
          </ul>                  
       </li>
      <li>
       <h2>Title</h2>
       <ul>
         
       </ul>                
      </li>  
    </ul>
    


    The second getResource doesn’t work! And the first grab all resources listed under resource ID 4 and not only first level children resources....
    Where am I doing wrong?

    Thank you
      • 4172
      • 5,888 Posts
      try this:
      [[$chunk2? &idd=`[[+id]]`]]


      or

      [[$chunk2?idd=`[[+id]]`]]


      or call it directly, not in chunk if that still doesn’t work:

      [[!getResources? &parents=`[[+id]]` &tpl=`ul-li-ul-li-tpl` &tplFirst=`ul-li-ul-li-first-tpl` &includeTVs=`1` &showHidden=`true`]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 8427
        • 14 Posts
        It works perfectly!!! Thank you Bruno!!! You’re my hero grin

        I forgot the "`":
        [[$chunk2? &idd=`[[+id]]`]]


        Correctly formatted, it works very well.