We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15152
    • 360 Posts
    I have a site that has a customized front page and I need to show the two most recent posts from the blog in their own section on that page. I only want the Title and a very brief description to show. Can someone help?

    I’m sure this isn’t too difficult. I’m a designer, NOT a programmer, but I love working with modX - used to use Joomla.

    Thanks for any feedback.
      There are no boring projects. Only boring executions. ~ Etzkorn
      www.impress-design.com
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Ditto!

      See the documentation on how to make a custom template for the output, and how to set the parameters for how many items to display.
        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
        • 8960
        • 150 Posts
        You do need to read the documentation, but here’s a DItto call I’ve used to display the content just as you described:
        [[Ditto? &startID=`2` &summarize=`3` &removeChunk=`Comments` &paginate=`1` &extenders=`date,summary,dateFilter` &dateSource=`pub_date` &dateFormat=`%b %d, %Y` &sortBy=`pub_date` &sortDir=`DESC` &paginateAlwaysShowLinks=`1` &tagData=`documentTags` &tplFirst=`DittoHighlight` &tpl=`DittoDisplay`]]

        Let’s break this down:

        • [[Ditto]] = this is the main call to invoke Ditto
        • startID = this is the ID # of the document (which is a folder) I’m going to be pulling the content from
        • summarize = this is the number of posts (if you’re thinking in blog terms) that I’m going to display
        • removeChunk = I don’t want to show any comments any of these posts might have on the homepage
        • extenders = I’m telling Ditto that I’m going to need & display the functions that relate to the date, summary, & dateFilter
        • dateSource = I’m telling Ditto where to grab the date from within each of these posts (createdon is another option)
        • dateFormat = Formats the date string according to my parameters
        • sortBy = sorts the order of th posts
        • sortDir = the sorting order (ASC is another option)
        • paginate... = I think this is to paginate the posts if they go past the number I’ve specified in &total (which I haven’t declared here)
        • tagData = enables tagging within Ditto of these posts
        • tplFirst = this is the template (which is another Chunk) the tells Ditto how to format the very first post
        • tpl = this is the Chunk template that specifies how to format all the other posts. These two last entried are crucial is you want to have your posts formatted differently as you described.

        And here’s my Chunk for the tplFirst (DittoHighlight):
        <div class="highlight">
          [+topstoryIMG+]
          <h3><a href="[~[+id+]~]">[+title+]</a></h3>
          <h5>Posted by [+author+] on [+date+].</h5>
          [+content+]
          <p class="more">[+link+]</p>
        </div>


        And my Chunk for the tpl (DittoDisplay):
        <div class="column-in">
          <h3><a href="[~[+id+]~]">[+title+]</a></h3>
          <h5>Posted by [+author+] on [+date+].</h5>
          [+introtext+]
          <p class="more">[+link+]</p>
        </div>


        These Chunks are nearly the same, but I’m applying different CSS stylings to them. Hope this helps!
          • 15152
          • 360 Posts
          Thanks, this should help a lot!
            There are no boring projects. Only boring executions. ~ Etzkorn
            www.impress-design.com
            • 30884
            • 142 Posts
            This is a great introductory tutorial and I’m please it’s helped me grasped some of the more basic premises with ModX etc. I have successfully tested this out but I’m a little lost when it comes to how you define / set the [+topstoryIMG+] asset up?

            I’m assuming that it’s something that Ditto is resolving from the article but I’m not having any success integrating any images on the ditto output?

            Please help!

            Cheers

            TXRX
              p i x e l p u s h e r e x t r o d i n a i r e
              A x i s A n i m a t i o n . c o m
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              That’s probably a TV, input type "image" and output widget "image".
                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
                • 8960
                • 150 Posts
                Quote from: sottwell at Apr 06, 2007, 11:06 AM

                That’s probably a TV, input type "image" and output widget "image".

                That’s exactly what that is. I didn’t mention it in the tutorial, and I meant to take it out of the tutorial, but since it’s there:

                • Create a TV called topstoryIMG
                • Caption: Top Story Image
                • Description: This image is displayed on the homepage above the 1st article. You must attach this image to the actual story before it will be displayed on the homepage.
                • Input Type: Image
                • Widget: Image
                • Widget Properties: select anything you want applied to your image
                • Template Access: select any templates this needs to work on
                • Call this TV within one of your Ditto templates like this: [+topstoryIMG+]
                • on your Documents, find this TV and click on INSERT to select an image from the images folder (I put my top story images here: assets/images/topstory/photo-story-01.jpg)
                Now the image will appear in the Document it is bound to. Note, I only used this call in one of my Ditto templates above because I only want that image showing on only the most recent Document.

                Hope that helps. I’ve included a screenshot of how I used this on a site. The non-green area is what is covered in this tutorial.
                  • 30884
                  • 142 Posts
                  superb stuff! I’ll give it a whirl and let you know how I get on!
                    p i x e l p u s h e r e x t r o d i n a i r e
                    A x i s A n i m a t i o n . c o m
                    • 30884
                    • 142 Posts
                    Yup, that works a treat. What I’m now attempting is to get it to use the first image in any maxi-gallery images. I guess I need to query the MySQL tables to find that out. I’m guessing that it’s not impossible and if I’m able to have any degree of success I’ll post it here.

                    Although if anyone else has done this before, let me know!
                    Cheers!

                    TXRX
                      p i x e l p u s h e r e x t r o d i n a i r e
                      A x i s A n i m a t i o n . c o m
                      • 18397
                      • 3,250 Posts
                      You might be able to call MaxiGallery using a gallery ID and specifying it only retrieve one image. You would need to look at the parameters in detail to see if it is possible.