We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36926
    • 701 Posts
    Hi,
    I want to be able to split the ditto results in to two columns.

    Down the left column i’m going to have news articles summary and in the right i will display the full content of one article at a time. This will change when the user clicks "more" from an article on the left. I can achieve the content changing in the right column by using jquery but what i’m not sure about is the best way to split the results i’m getting from the ditto call. I’ve read through the forums and the best i can find is doing 2 ditto calls. First one calls the title summery and url link ect. And the second call just displays the content.

    Does it sound the best way to achieve this, is to have two ditto calls, or is there an better way to do this.

    Many Thanks

    Ben

    Ben
      • 3749
      • 24,544 Posts
      I guess you could use .CSS to hide all the other articles in the right column, but I think 2 Ditto calls would be a lot more efficient and much easier to implement.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 7231
        • 4,205 Posts
        2 Ditto calls will work.

        If you are displaying only one article at a time you could you could use a simpler snippet to retrieve the data like GetField. Or you can do it programmaticaly through the api with modx->runSnippet()
          [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't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 29774
          • 386 Posts
          Two Ditto calls adds unnecessary overhead.

          You can easily use jQuery to manipulate the dom and split the results into two columns as you describe, and this is the approach I would take since it makes semantic sense to have the headlines and summary text outputted in a linear order: it makes it accessible to screen readers and search engine friendly.

          However, you could also write your own snippet and run Ditto with $modx->runSnippet() - the Ditto save parameter can be used to save the resultset as a placeholder, which you can then iterate through and format as you wish.
            Snippets: GoogleMap | FileDetails | Related Plugin: SSL
            • 3749
            • 24,544 Posts
            Quote from: dev_cw at Aug 11, 2008, 06:09 AM

            2 Ditto calls will work.

            If you are displaying only one article at a time you could you could use a simpler snippet to retrieve the data like GetField. Or you can do it programmaticaly through the api with modx->runSnippet()

            If you know the document ID, this snippet should get the content and display it with minimal overhead:

            echo $modx->getDocument($id, 'content'); 
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 36926
              • 701 Posts
              Thanks for all you replies. So guess a few ways to do it. Got it working fine with 2 ditto calls. But i’m going to look at some of the other options as well, always good to try all possibilities.

              Many Thanks

              Ben