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

    I’m very new to modx and I’m looking for some pointers. I’m converting an existing site to modx to help with content management. The site has a right-hand column that contains 3 <div> section containing ’deals of the day’. At the moment these are hardcoded in the pages, but i would like to put them in the database and write a Snippet to extract 3 random items per page. What i can’t quite get my head round is where I should store the content. Should it be in a Chunk, TV, or something else. I want to be able to add and maintain this information from within modx. Each ’deal’ can also have a picture associated with it.

    I’d be grateful for any help. Any example of the site can be seen at www.mavis-crafts.com/travel/

    Thanks,

    Allen
      • 7455
      • 2,204 Posts
      take a look at Ditto (included with the release)
      that wil help you
        follow me on twitter: @dimmy01
        • 1176
        • 8 Posts
        Quote from: Dimmy at May 12, 2008, 01:23 PM

        take a look at Ditto (included with the release)
        that will help you
        As I said, I’m very new to modx, looking through the Ditto documentation it is obvious that this can do a lot of things, but where to start! It’s a bit overwhelming. Can you give me some hints on where to start?

        Thanks,

        Allen
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          1. Create a folder/container document to put your "deals" documents in.
          2. Create your "Deals" document under the above folder/container document.
          3. Make a chunk or a TV for the sidebar with the Ditto call to pull up a random "Deal" document. Ditto can be configured with its parameters to filter by subject or date or anything else you might want.



            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
            • 1176
            • 8 Posts
            Thanks for all your help. It’s slowly beginning to sink in, although I’m still not sure about what Ditto call to make to return random documents. As I said in the original post I want to display 3 random documents, but I don’t want any to be the same. How can I do that in Ditto?

            Thanks,

            Allen
              • 31037
              • 358 Posts
              I think the &randomize parameter in your snippet call would do it.

              Check http://ditto.modxcms.com/files/snippet-ditto-php.html for the randomize parameter and for a list of other options.

              And set the &parents parameter to the container where you have the docs you want to be listed.
                • 1176
                • 8 Posts
                I’m definitely starting to get the hang of this!  I now have Ditto picking 3 random documents from a container and displaying them in my right column.  Does anyone know how I can associate an image with each of these documents to display along side the text ?

                Could I maybe create a child document or weblink that somehow Ditto can retrieve and use?

                Thanks,

                Allen
                  • 7455
                  • 2,204 Posts
                  Create a template variable (tv) and add that one to you ditto template. now fill the tv on the documents with your image and ditto will pick the image up and put it in the template.
                    follow me on twitter: @dimmy01
                    • 1176
                    • 8 Posts
                    Perfect! Thank you for all your help. I now have a right column that contains 3 randomly chosen documents, and images displayed next to each. It has only been possible thanks to all your help. When I become more experienced with modx I will certainly look at giving back to the project.

                    Thanks again.

                    Allen