We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9696
    • 4 Posts
    I’m new to MODx, but I love it already!

    However, I’m stuck trying to figure out how to create a product catalog using child documents and TV’s.

    For example,

    - I wish to create a document for a group of products called Drinks.
    - Drinks has a number of child documents, each of which is a different Drink.

    I want to be able to create a grid of all the child documents (each Drink) which updates automatically when a new child document is made within Drinks.

    I am currently using a TV for the thumbnail image for the grid, but also wish to use the Title or Description of the individual drinks in the grid of all the products.

    I have looked at Ditto, but I don’t know how I would withdraw the TV’s and the Title/Description from each of the child documents. I had considered using some kind of for loop to cylce through all the child documents, but I assume their is a more elegant way.

    I’m surely missing something really obvious here, but any help would be most appreciated!


    Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That’s exactly what Ditto is for. Simply use placeholder tags in your Ditto chunk tpl [+pagetitle+] or [+tvname+] instead of the usual [*...*] tags. You can use all of the usual [*...*] document variables as well as any TVs you have for the item’s template.
      Your chunk might look like this (the image display code would depend on if you are using an image output widget for the image TV or not):
      <div class="ditto_item">
      <h2>[+pagetitle+]</h2>
      <p>[+introtext+]</p>
      [+imageTV+] (or <img src="assets/images/[+imageTV+]" alt="Product" />)
      </div>
        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
        • 9696
        • 4 Posts
        I tried implementing a fairly simple Ditto, but I couldn’t get any response. I don’t think I am understanding the relationship between which documents Ditto extracts information from.

        Here is my document structure:

        Drinks (id=2), then two pages within it, Drink1 (id=3) & Drink2 (id=4).

        I wrote a chunked called alldrinks with this code:

        [+title+]


        In the content area on the document Drinks (id=2) I wrote the call

        [!Ditto?  &tpl=`alldrinks`!]


        I assumed that this was the parent document to the documents Drink1, and Drink2 it would extract the document titles from each, however nothing was returned.

        When I inserted something like a <h1> into my chunk, that wasn’t displayed either.

        I’m surely missing something simple, again, but any help would be most appreciated!

        Thanks again for the initial support, and it is great to see a community that is so will to help out!

        Thanks.



          • 4172
          • 5,888 Posts
          [!Ditto?  &tpl=`alldrinks`!]


          this should work,
          if you are on page with id=2 on frontend,
          your drink-documents(3+4) are under id2 as subdocuments.
          these subdocuments are published.

          if you are on page id=2 and there are no subdocuments you should see ’no documents found’ or something like that.

          did you also try this in your chunk `alldrinks`?:
          <h2>[+pagetitle+]</h2>




            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 9696
            • 4 Posts
            Embarrassingly I over looked something very simple in my eagerness to test out Ditto.

            I forgot to include [*content*] in my Template!!!

            That’s why it didn’t show anything!

            Thank you so much for your support. I’m looking forward to seeing more about the MODx community soon!

            Thanks!