We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3349
    • 126 Posts
    Hi

    I am currently using the listIndexer snippet to display a list of Events. Currently they are being ordered by creation date. I know I can change this ’’createdon’ date order to ’editedon’ date OR change the order to ’alpha’ or ’menuindex’

    BUT

    What I’d like to order it by is the event start date. I have created a TV called EventStartDate for each Event.

    Can someone tell me how I can order my Events by this TV please?

    Thanks in advance

    bS
      • 18397
      • 3,250 Posts
      You can do this with Ditto. There is a tutorial available here: http://ditto.modxcms.com/tutorials/sort-by-a-date-tv.html
        • 3349
        • 126 Posts
        Hi

        Thanks for the reply but im still not sure how to execute this? Do i no longer need to use ListIndexer?

        If so, how do I then use Ditto to call all sub documents from the parent document? And then what do I do to order by mt date TV?

        Sorry for my lack of knowledge

        Regards

        bS
          • 18397
          • 3,250 Posts
          You would use Ditto to execute this. To get all sub documents (assuming you have at least Ditto 2.0.2) just append &depth=`0`. As for the date sorting, follow the tutorial in my previous post.
            • 3349
            • 126 Posts
            I still can’t seem to get this working. If I can explain my situation:

            I have a document (id=54) executing a Ditto call [[Ditto? &parent=`71` &depth=`0` $display=`5` &sortBy=`EventStartDate` &dateSource=`EventStartDate`]]

            I have a container (id=71) containing 5 documents (events)

            All Im getting is list of 5 documents but not ones specific to that parent id?

            Can you help me further please

            Thanks

            bS

              • 18397
              • 3,250 Posts
              &parents (note the s)
                • 3349
                • 126 Posts
                Oh dear! Thanks...

                So how do I format the unixtime field when not using the ditto snippet? (Since I had to change the TV to UNIXTIME instead of the original Date Formatter)

                Its fine when in the events list page as I can format with the ditto snippet but when in the actual event page, since im calling is [*EventStartDate*] im getting it as a unixtime format??

                how can this be formatted?

                Thanks again

                bS
                  • 18397
                  • 3,250 Posts
                  You can either use the DateFormat snippet or PHx.
                    • 3349
                    • 126 Posts
                    Hmmm? Came across another issue....

                    When I used the ListIndexer snippet, I could modify the following code and insert a TV value EventType and call it

                    ----------------

                    $EventTypeClass=$tvEventType[’EventType’];

                    // Link to page
                    $output .= ’<td class="’.$EventTypeClass.’">’.$EventTypeClass.’
                    <a href="[~’.$recentRecord[’id’].’~]" title="’.strip_tags($recentRecord[’pagetitle’]).’">’.$recentRecord[’pagetitle’].’</a></td>’;

                    -----------------

                    How can I add this into the english.inc.php file? (Im presuming this is where you can change the outputted code)
                    Currently I have:

                    ----------------

                    <tr><td class="eventdate">[+date+]</td><td><a href="[~[+id+]~]">[+pagetitle+]</a></td></tr>

                    ----------------

                    I’ve tried adding in code as in the 1st example but it doesn’t like it....

                    Thanks again

                    bS
                      • 18397
                      • 3,250 Posts
                      Follow this tutorial for custom templating: http://ditto.modxcms.com/tutorials/creating-a-custom-template.html