We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16895
    • 87 Posts
    [Evolution 1.0.2, Ditto 2.1]

    I’m trying to create a news feed of future events, showing the ones that are closest first.
    This is the Ditto call I’m using to show the first event:

    [[Ditto? &parents=`11` &orderBy=`event_date ASC` &display=`1` &total=`1` &tpl=`story_summary` &dateSource=`event_date` &noResults=`no_events` &dateFormat=`%d %B %Y` ]]


    story_summary looks like this:
    <h3 class="date">[+date+]</h3>
    <p>[+introtext+]</p>
    <p class="continue"><a href="[~[+id+]~]">Read more</a></p>


    event_date is a template variable with a user-chosen date for each news item resource. However, the date displayed by [+date+] is 1 January 1970. Ditto, for some reason, can’t be reading this template variable correctly. If I change the dateSource to createdon, then today’s date (on which I created the articles) is shown, so that works fine. Unfortunately I need to show the template variable date because that’s when the event happens.

    I don’t think that sorting is working either.

    Am I doing something wrong? Is there a different way of calling template variables?
      • 16278
      • 928 Posts
      How is event_date defined? It needs to use the Unixtime widget to work with Ditto’s sorting and date functions.
      smiley KP
      http://www.pogwatch.com/ditto/ditto-dates.html
        • 16895
        • 87 Posts
        Brilliant laugh; I had seen references to the unixtime widget in other similar threads but I didn’t know how it was relevant.

        I think everything’s working now, now just working out how to filter out events that have already happened. (Is it better to use an unpublish date or an &filter?)
          • 16278
          • 928 Posts
          Personally, I’d go for an unpublish date unless you have so many items to enter that it becomes too much hassle. It means you can set an event to stop showing at the beginning of the day after it happens (as I want for the engagements list of the brass band I play in, for example), and generally it just keeps things simple.

          There are examples of filters with an eval statement using now() in several recent threads if you do decide to use a filter.
          smiley KP
            • 16895
            • 87 Posts
            I’ve gone with a time() EVAL to keep it automatic (don’t know that the people maintaining this website will be able to cope with setting an unpublish date for everything). If it causes any problems then I can just add a few thousand seconds to it.

            Thanks for the help,
            Ross