We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31876
    • 33 Posts
    Parlez-vous français?
    Well Ditto is fine, as Wayfinder.
    but...

    I have in my tree some folders with inside about 10 children.
    Is it possible to list children (like ditto do) with each one personalized tpl?

    maybe link the tpl to the doc... How? Another snippet?
    ex : one doc with a tv=image, one with a tv=text, the resulting list will contain image..text

    (typolight makes that automatically : articles are listed one above the other in a page :’()

    I need that because I can’t organize documents in another way in my website.
    Sorry for the English... grin

    Thanks for reading.
      • 1122
      • 209 Posts
      Create TV variable (type textarea should be suitable) named, for example, "show-in-list-as" and add it to each template that your documents are based on. (It is a good idea to define default value for this variable.) Next design your Ditto call for aggregating documents:
      [[Ditto? &parents=`...` &depth=`...` &display=`...` &tpl=`tpl-list-item` ...]]
      

      As you can see chunk "tpl-list-item" defines how a single document shoud be displayed/aggregated in list. In this chunk you should call your TV variable "show-in-list-as" that customizes the layout of a single list item:
      [*show-in-list-as*]
      

      Now edit your documents and customize values for "show-in-list-as" (i.e. templates for the use in Ditto calls). Good luck with this idea.
        • 31876
        • 33 Posts
        Thank you Alik, I tried it and...
        In a more "general" usage it’s working fine (except in the chunk I had to name tv [+show-in-list-as+] to make it work)...

        ...Unfortunately for me it’s doesn’t, sorry I forgot to tell all the story :

        In a child doc (pagetitle of doc="document-name") containing an image for example : the image is in a tv named "postimage".

        So now following your idea :

        in the tv "show-in-list-as" I had to write something like :
        <div class="doc-type-image">
        ...
        <img title="[+pagetitle+]" src="[+postimage+]">
        ...
        </div>
        


        And that doesn’t work :
        the result in the source of the final HTML is :
        <img src="" title="document-name"/>
        


        A you see, MODx fills ok the document variable "document-name", but doesn’t fill the tv "postimage" undecided
        I think it’s a "recursive" problem huh I think...

        Maybe there is a solution to make it work with PHx, but I don’t know how it works...



          • 7231
          • 4,205 Posts
          You can use PHx inside Ditto tpl to add logic and have that control the output.

          For example if you want the image to show only if an image is available you can use:
          [+postimage:if=``:then=``:else=`<img title="[+pagetitle+]" src="[+postimage+]">`+]


          PHx is available to use within Ditto TPL chunks, no need to install the PHx plugin.
          http://wiki.modxcms.com/index.php/PHx
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don&#39;t know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 1122
            • 209 Posts
            Yes, it’s recursion problem. We need to separate/instantiate Ditto calls. Insert into your "tpl-list-item" chunk this:
            [[Ditto? documents=`[+id+]` ... &tpl=`@CODE:[+show-in-list-as+]` ...]]
            

            Type the content of "show-in-list-as" in a single line.
              • 31876
              • 33 Posts
              Alik : I went to your website (cool!), I’ve seen a post about MySql 5.051... It is the version I use. You think the pb may come from that?

              dev_cw : thank you, I tried that.. Well it’s ok,
              If I have... 30 kinds of diffent documents in my website (image, text, something, something-else......), in the ditto tpl I have to write complex conditional statements, it’s not a problem except the heavy syntax, maybe I’m wrong :

              I explain:

              I created a tv assigned to my docs named "bloctype" that I use to say "my bloctype is : image" or "my bloctype is : text".... (radio button)
              So now I must have a conditional Ditto tpl like that, is it right? :

              [+bloctype:is=`image`:then=`<div class="zone-image">......</div>`:else=`[+bloctype:is=`text`:then=`<div class="zone-text">......</div>`:else=`[+bloctype:is=`someting`:then=`<div class="zone-text">......</div>`:else=`[+bloctype:is=`somethig-else`:then=`<div class="zone-text">......</div>..................(can be long)
              


              True?
                • 4172
                • 5,888 Posts
                maybe you need also the parameter &hiddenfields=`postimage`. Thats if you have placeholders in nested chunks etc. and Ditto doesn’t know about this TVs to fetch them from database.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 31876
                  • 33 Posts
                  Bruno17 : thanks, but I tried : seems nothing changed... always showing img src=""
                  Alik : sorry I didn’t look at your precedent post, I will try that, thanks.
                    • 4172
                    • 5,888 Posts
                    sorry, it must be &hiddenFields=`postimage`
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 31876
                      • 33 Posts
                      Alik : I understood it had to work... tried.. nothing changed.
                      Bruno17 : wow... I think it’s working!, case-sensitive shocked .... trying this with all the docs and I come back here!