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

    Is there a way to specify a different template for folders when we use Ditto ?
    We have a parameter that can show or hide folders but I can't find any to specify a template for those items ?

    Any ideas ?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The idea that comes to mind is to put 'class="folder"' in one of the folder resource's fields, perhaps the description, then put [+description+] in the tpl where a classname would be appropriate; it won't insert anything in items that don't have a value in that field. Then you can style it as you like.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 36416
        • 589 Posts
        Quote from: jchirschy at Sep 25, 2013, 05:29 PM
        Is there a way to specify a different template for folders when we use Ditto ?
        We have a parameter that can show or hide folders but I can't find any to specify a template for those items ?

        You can use PHx condition (built-in or standalone) for logic inside template:
        [+isfolder:eq=`1`:then=`...`+]
        

        http://rtfm.modx.com/evolution/1.0/designing/adding-modx-tags/resource-fields
          • 45206
          • 32 Posts
          Hello,

          Eoler' solution is great, but it seems that PHx forget some placeholders like [+introtext+] or other TVs.

          I use Ditto to list all ressources from a directory.
          That directory has subfolders.
          So I wrote this in the tpl that is called by Ditto :
          [+isfolder:eq=`1`:then=`{{infosUtilesDossierTpl}}`:else=`{{infosUtilesTpl}}`+]


          It works just fine, the right tpl is used, but datas is missing.
          For example, in the chunk infosUtilesTpl, I wrote :
          <p>
          	<a style="display:block;" href="[+fichierATelecharger+]">[+pagetitle+]</a>
          	[+introtext+]
          </p>

          introtext and the TV fichierATelecharger are blank.
          When I call directly the chunk infosUtilesTpl, introtext and fichierATelecharger do appear.

          Any ideas ?
          Thanks in advance.
            • 36416
            • 589 Posts
            Quote from: jchirschy at Sep 30, 2013, 04:30 AM
            introtext and the TV fichierATelecharger are blank.
            When I call directly the chunk infosUtilesTpl, introtext and fichierATelecharger do appear.

            The problem comes from using chunks - a level too deep for Ditto parsing required fields from your templates.
            Solution - use hiddenFields parameter:
            [[Ditto?... &hiddenFields=`introtext,fichierATelecharger` ]]
              • 9995
              • 1,613 Posts
              Cool, didn't know that hiddenFields worked/could be used like that.

              Last week I had a dittocall and called a chunk into the tpl, accedently it worked because I still had the outsourced tv in the tpl there like;

              <!-- [+title+] -->


              after removing it there was no title.
              adding it back again it worked, now I can use hiddenfields for it lol.
                Evolution user, I like the back-end speed and simplicity smiley
                • 45206
                • 32 Posts
                Wonderful. That works perfectly using PHx condition (Ditto builtin) and using hiddenFields parameter.

                Thanks a lot.