We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22213
    • 52 Posts
    I’ve been looking at some older threads, to find out if NewsListing can support ordering by a date other than posted date.

    The requirement is for a schedule of events for a music venue. I want to handle each event as a NewsListing, with TVs for time, price, band name, type of music, and description, etc. Because of the extended information, it’s easy to choose NewsListing over DropMenu...

    But I need to present a list of the events, starting with the event that will next occur, and going forward into the future. This isn’t a listing by date created, which I still need for other purposes. So the questions are, I could add a TV to the template I use for event listings, but

    1. can I get a NewsListing to sort by an added TV date, and

    2. can I get it to start listings automatically at the next future date?

    Because the music at the club is of many kinds (Salsa, Samba, etc) that attract different crowds, it suggests a third question (not as critical)

    3. can I apply 1. and 2. while only showing listings classified by yet another TV attribution?

    I’m hoping for out-of-the-box behaviour, but I can hack PHP and MySQL queries if I have to. If this functionality doesn’t exist, is anyone looking for similar scheduling capability? Can anyone point me to any similar sites using MODx?

    Many thanks in advance
      Web Designer
      PHP Programmer
      Cocoa Developer
      Boulevardier & Arriviste
      • 18397
      • 3,250 Posts
      Answers:

      1. Yes
      2. Could you please clarify "start listings automatically at the next future date?"
      3. Yes, via the filter param

      Banzai’s site at http://tattoocms.it/ is using NewsListing with filters. I have several sites (not public ATM, sorry) running with multiple filters and custom sorts.

      If you need specific help with setting this up, let me know.
        • 22213
        • 52 Posts
        Quote from: Mark at Mar 31, 2006, 07:19 PM

        Answers:

        2. Could you please clarify "start listings automatically at the next future date?"


        I just mean that if its the 25th of March, I should not see events prior to the 25th of March in the default listing.

        is that another filter param thing?
          Web Designer
          PHP Programmer
          Cocoa Developer
          Boulevardier & Arriviste
          • 22213
          • 52 Posts
          and say, where is that ’filter parameter’ thing at, anyhoo?

          Haven’t found that yet...
            Web Designer
            PHP Programmer
            Cocoa Developer
            Boulevardier & Arriviste
            • 18397
            • 3,250 Posts
            The filter paramater is in the latest edition of NewsListing 6.3.3 available in the forums.

            Yes, what you describe is completely possible so long as the dates are either stored as or converted to UNIXTIME (very easily done). You could even use the Date Widget I think!
              • 22213
              • 52 Posts
              Quote from: Mark at Apr 01, 2006, 06:29 AM

              The filter paramater is in the latest edition of NewsListing 6.3.3 available in the forums.

              found it. Brilliant. Realize now I had version 4.4 installed.

              Quote from: Mark at Apr 01, 2006, 06:29 AM

              Yes, what you describe is completely possible so long as the dates are either stored as or converted to UNIXTIME (very easily done). You could even use the Date Widget I think!

              Hmm. I created a TV, of type Date, with a date formatter on it. But I see that the type of field that it is stored in is a text field, and that the value is a date string. [eg 30-03-2006 00:00:00]. Is this a problem? if I set up a filter to only return records where a date is after a certain date, are you saying that I need to present the argument to the filter as unixtime? Or do you mean that I have to store the TV data for each listing as unixtime? Do I have to hack the NewsListing source to do so, or is there some kind of function that I can invoke?

              Also, related but slightly OT, how in general do I handle presenting formatting of dates in different ways, when the data is stored as a TV? Is this taken care of?
                Web Designer
                PHP Programmer
                Cocoa Developer
                Boulevardier & Arriviste
                • 18397
                • 3,250 Posts
                It would need to be translated to UNIXtime first to compare > or < dates. (Thats the only way you can do this in PHP AFAIK).

                A simple way to do this would be to create 2 tvs. One for the actual date and the other one for a unixdate. Then you can have the default value of the 2nd tv be a @EVAL php line to convert the text string to unixtime. You would then use the 2nd TV as the sort.

                You can alter the display of the Date TV via the Date Formatter widget [http://modxcms.com/what-are-widgets.html].

                The best solution would be to add a widget called Unixtime which does the text string to unixtime conversion. (NewsListing uses the TV output for sorting, not the raw unformatted stuff)
                • there are a number of date manipulation functions in PHP.

                  http://il.php.net/manual/en/ref.datetime.php

                  And MySQL has some very interesting functions you can embed right into a query. It is much better to handle things in the database instead of your script whenever possible.

                  http://www.databasejournal.com/features/mysql/article.php/2172731
                  http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html

                  In fact, you can even use a query to directly retrieve a formatted date/time stored as a timestamp instead of having a separate php function.
                  SELECT FROM_UNIXTIME(unix_timestamp [,format_string])

                  A subquery here would be very useful to get the desired timestamp:

                  http://www.databasejournal.com/features/mysql/article.php/3434641
                    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
                    • 22213
                    • 52 Posts
                    So I’m working on something that will extract a value from a tv and convert it to unixtime. A question and a suggestion:

                    Question: - in an @EVAL, is there a way to directly access a tv value for the current record, or do I need to query the db to do it?

                    Suggestion: - it would be nice to have dates stored consistently, rather than using a formatted date in tvs while storing other dates as unixtime. Is there a reason it wasn’t done this way?
                      Web Designer
                      PHP Programmer
                      Cocoa Developer
                      Boulevardier & Arriviste
                    • You can store a TV any way you like. Storing dates as Unix timestamps is faster, takes up less space, and is handy for doing date arithmetic. Actually, you should format the date from the timestamp in the SQL query, as well as doing any date calculations, rather than retrieving the timestamp and using a PHP function to format it or do calculations.

                      http://www.databasejournal.com/features/mysql/article.php/2172731
                        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