We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30734
    • 44 Posts
    Would adding the ability to sort by a date TV be something easily done for Archivist? I don't have the know how to put this together myself but it cases where you want to do an archive for an event list instead of a blog I think it would be helpful to be able to sort by a TV for the event date as apposed to the publish date.
      • 23018
      • 353 Posts
      +1 for that feature request.

      Even though this question is over 1 a year old, I think it is worth answering.

      I had a quick look at the code and from what I have learned, it can't be done easily. Trying to find a workaround that doesn't depend on hacking archivist. If I find one, I'll post it here, but don't expect anything soon.

      Regards,

      pepebe [ed. note: pepebe last edited this post 10 years ago.]
        Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
        • 23018
        • 353 Posts
        OK, this is a bit hacky AND might be for some reason COMPLETLY stupid, but I solved the probem this way:

        1. This only works if createdon is not important for you in any way.

        2. Overwrite "createdon" with a plugin that gets triggered everytime the document is saved:

        /*
            Copy value of a dateTV into createdon field onDocFormSave event
        */
        $tvName = "Name-of-your-Date-TV"; /* Example: event-start */
        $templateID = "ID-of-the-Template-where-the-plugin-should-be-triggered"; /* Example: 10 */
        
        switch ($modx->event->name) {
            case 'OnDocFormSave':
                if ($resource->get('template') != templateID) {
                    return;
                }        
                
                $date = strtotime($resource->getTVValue($tvName));
                $resource->set('createdon',$date);
                $resource->save();
                break;
        }    
            
        return;


        3. Set the sortBy parameter in archivist and getArchives to "createdon".

        Regards,

        pepebe
        [ed. note: pepebe last edited this post 10 years ago.]
          Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
          • 21800
          • 174 Posts
          hej,

          the code doesn´t work for me with MODX Revolution 2.4.2-pl and Archivist 1.2.4-pl

          :-(