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

    Is it possible to have ditto use multiple templates... consider this example:

    I want to list 10 items. The items are pages that use different templates, e.g. a press release (Press Page) and a corporate event (Event Page).

    I want Ditto to use different ’ditto templates’ for the different ’page templates’. If it sees the item is a ’Press Page’ it will output using the template ’press_item_template’, and if it sees the item is a ’Event Page’ it will use ’event_item_template’.

    Is this possible without some serious jiggery pokery? shocked

    Regards:


    John
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I would make the Ditto calls in TVs, and have each template’s TV with the appropriate Ditto call.
        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
        • 14556
        • 9 Posts
        Could you elaborate? huh Do you mean actually place the Ditto command as the content of a TV? Could you please give me a bit more guidance?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I do this all the time for sidebar content. Make a TV, assign it to a template so docs using that template will get it, then make it a "textarea" type, and for the default just put in the desired Ditto call. Then put the TV tag in the template where you would normally put the Ditto call. Edit whatever needs to be edited on a page-by-page basis.

          I usually use @INHERIT as my default, that way you only have to edit the TV for the parent doc/folder of each section. For example, if you had document 3 as a parent for a subsection, edit document 3’s copy of the TV to have the Ditto call, with the startId as 3, and all of its children will inherit that Ditto call.

          With this sort of thing, you may not even need multiple templates. Just use TVs for your various sidebar, menu, and other unique blocks with @INHERIT and edit for each section in the section parent’s TV.
            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
            • 14556
            • 9 Posts
            Hey sottwell:

            Thanks for the feedback... I ended up doing it another way. Seems very simple to me once I worked it out. I am a relative ModX newbie so please tell me if this is a pile of sh**e.

            There is my MAIN Ditto call within my Page Template
            [!Ditto? &startID=`[*id*]` &tpl=`scroller_repeater` &noResults=` ` &display=`all` &sortBy=`title` &sortDir=`ASC`!]


            And the Chunk ’scroller_repeater’:
            [[Ditto? &documents=`[+id+]` &tpl=`scroller_[+template+]` &noResults=` `]]


            Now all you need to do it create chunks for all the types of templates based on the ID of the template used for the sub-pages.

            e.g.:

            scroller_6
            scroller_7
            scroller_8
            scroller_9

            ...the number at the end relating to the template id.

            Does this make sense or help anybody else?
              • 36624
              • 535 Posts
              i think your solution is great for 10 documents.

              note for later : if one day you have more documents in your list, try SSR snippet to reduce drastically the number of SQL queries. Very useful when you have a call in a ditto call..
                CTRL+SHIFT+U - Clear Cache
                CTRL+SHIFT+H - Hiding Heft Panel
                CTRL+SHIFT+N - Fast Create Resource
                CTRL+ALT+P - Preview Recource (in edit resorce window)
                CTRL+ALT+S - Save