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

    I am trying to get content from one page to post fully on a parent page based on publish date. These are devotionals that I create under a parent, but I would like to have the parent to have the current devotional to be posted on the parent. Just need help to where to get started. I have tried playing with getresources and have yet to get it working.

    I am using Revolution 2.4.1 With Flexibility 4.

    Thanks
    • [[getResources? &parents=`[[*id]]` &includeContent=`1` &limit=`1` &tpl=`resourceTpl`]] 

      The resourceTpl chunk:
      <div>[[+content]]</div>

      Adjust the HTML structure of the tpl chunk as necessary to fit in with your theme, the important part is the content placeholder.

      By default getResources sorts by date, so when fetching only one it will be the latest one.
        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
        • 32347
        • 143 Posts
        Hello Susan,
        Thanks for your response.

        It worked, which you probably know..lol
        But I need to get it to sort so that the newest posted child will be displayed, so that every time I add a new post either by adding an article or by a publish date. I tried different sort, but I am not able to get it to work. Matter of fact when I add it is stops showing anything. Example below.

        [[getResources? &parents=`55` &includeContent=`1` &limit=`1` &tpl=`resourceTpl` &sortby=`id` &sortdir=`ASC`]]

        Tried this also, &sortby=`{"publishedon":"ASC","createdon":"DESC"}` and variations of it

        Thanks for the help!
        • The default sort order should be good, it is publishedon in the latest versions.
          [[getResources? 
            &parents=`55` 
            &includeContent=`1` 
            &limit=`1` 
            &tpl=`resourceTpl` 
          ]]
            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
            • 3749
            • 24,544 Posts
            If you do need to set the sort, try this:

            &sortby=`{"publishedon":"DESC"`}


            You can also add a subsidiary sort method. This will sort by publish date, then by pagetitle:

            &sortby=`{"publishedon":"DESC"`,"pagetitle":"ASC"}
            [ed. note: BobRay last edited this post 8 years, 1 month ago.]
              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
              • 32347
              • 143 Posts
              Quote from: BobRay at Mar 12, 2016, 06:01 PM
              If you do need to set the sort, try this:

              &sortby=`{"publishedon":"DESC"`}


              You can also add a subsidiary sort method. This will sort by publish date, then by pagetitle:

              &sortby=`{"publishedon":"DESC"`},"pagetitle":"ASC"}

              thanks Bob and Susan. I am beginning to understand. Bob when I added the &sortby=`{"publishedon":"desc"`} it does not work. Susan's get resources does give me the page current page published. I am not sure why Bob's sortby is not working, but will continue to work on it. What do you guys think about using the acrticle and archiving for this application?
                • 3749
                • 24,544 Posts
                Sorry, it should be:

                &sortby=`{"publishedon":"DESC","pagetitle":"ASC"}`
                [ed. note: BobRay last edited this post 8 years, 1 month ago.]
                  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
                • If all you want to do is display the latest item, there's no need for anything fancy.
                    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
                    • 41255
                    • 19 Posts
                    The second backtick should be placed on the end.

                    &sortby=`{"publishedon":"DESC","pagetitle":"ASC"}`