We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37514
    • 178 Posts
    I’ve a call:

    [[Ditto? &startID=`449,333,231,125,55` &orderBy=`pub_date DESC` &format=`atom` &tpl=`atom_tpl` &summarize=`20` &total=`20`]]

    and the template chunk has placeholders:

    <entry>
    <title>[+atom_escaped_pagetitle+]</title>
    <link rel="alternate" type="text/html" href="[+url+]" />
    <author><name>[+atom_author+]</name></author>
    <id>[+url+]</id>
    <updated>[+atom_editedon+]</updated>
    <published>[+atom_createdon+]</published>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">[+content+]</div></content>
    </entry>


    But I can’t find placeholder for publish date and atom. The result seem to be that the entries order themselves by the edited date, rather than publish date. Any ideas how I might change this?
      • 1122
      • 209 Posts
      Your code is not sorting by "pub_date" database field because this field is not retrieved by Ditto at all for the purpose of generating atom’s output item. In order to do such sorting, you need to extend/modify "atom.format.inc.php" in your MODx installation: 1) add/introduce placeholder for pub_date, 2) add date conversion function for introduced placeholder (atom rss uses its own format instead of Unix timestamp), 3) add placeholder to tpl, 4) finally test. I did for you steps 1-3 in attached "atom.format.inc.txt" (rename it to .php and place in correct location of your MODx installation; all my intrusions are marked with #### ...added/modified stuff... ##). You need to do step 4. Please let me know whether it works or not.
        • 36635
        • 41 Posts
        Another way is to add "atom_date", like rss_date, as a parameter for the template, too bad we have to touch the source...

        $placeholders['atom_date'] = array($GLOBALS["dateSource"],"atom_date");
        


        then you can set dateSource in Ditto to pub_date like you would for rss format. you can just add that line at line 46 to atom.format.inc.php.

          • 37514
          • 178 Posts
          Thanks both: I’ll try these and post how I get on. Sorry I’ve not replied sooner!