We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22213
    • 52 Posts
    Following up on the NewsListing for Schedules thread, I’ve discovered that when sorting newslisting output, it only works if the tv is actually rendered to the page. Correct me if this is wrong, but that’s what it seems.

    Can I suggest that this be modified? Surely if a NewsListing call has a tv as a sort parameter, there’s no need to actually write the value to the screen? In my case, the value is a numeric unixtime value, of no interest apart from sorting purposes. I’ve encased it in a comment, so it doesn’t appear on the page, but only in the source.

    The NewsListing is a great, incredibly useful tool, but this idea of tying sorting it to what actually gets put into the page seems like a limitation. Surely the distinction between metadata-values for sorting and display data should be made. What if the sort is a value I don’t want to display, even in code?

    Of course, it might turn out I’m confused.
      Web Designer
      PHP Programmer
      Cocoa Developer
      Boulevardier & Arriviste
    • If that’s the case, then it’s surely a bug. That doesn’t make sense.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • If the Unix timestamp is in the page output at all, it should make no difference whatsoever if it’s in a comment and thus not displayed by the browser. That’s purely a browser issue. I suspect there is something else at work here.
          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
          Quote from: sottwell at Apr 05, 2006, 04:08 PM

          If the Unix timestamp is in the page output at all, it should make no difference whatsoever if it’s in a comment and thus not displayed by the browser. That’s purely a browser issue. I suspect there is something else at work here.

          I’m pretty confident that the issue is rendering here, and if it is, I would agree with Ryan that it’s a bug. Here is how I tested it:

          - I ensured that the unixtime stored in the DB was correct for the current date set for the event

          - I ensured that the tv with the unixtime in it was being rendered into the NL chunk

          - I ensured that the sort tv was the unixtime one

          I then loaded the page where the NL is called, and confirmed that the correct sort happened.

          I then altered the date of one show, and observed via phpmysql that the value changed in the unixtime tv (in other words, the EVAL that writes the new value had happened.

          - I altered the chunk so that the sort tv would not be called

          - I then reloaded the page where the NL is called

          - the same sort order as before the date/unixtime change was observed. Reloading several times did not alter the order

          - I then altered the NL chunk, so that the tv would render into the page

          - on reloading the NL page, the correct sort order was observed.

          So, it does seem to be the case that when sorting, if the sort tv is not found in the chunk used to render the item, it fails, or uses a different, default sort.

          If there is anything else at work, then I’d be interested in knowing what it is. Perhaps a cacheing issue within modx? are TV values persistent in any way? IE could it be the case that when the TV is not rendered, then MODx has no occasion to re-evaluate its value against a cached one, so it uses the old sort order? As I mentioned, the sort order seems to persist. That is, when an unrendered change takes place, the sort reflects the sort order the last time it did render...

          Ideas?
            Web Designer
            PHP Programmer
            Cocoa Developer
            Boulevardier & Arriviste
            • 18397
            • 3,250 Posts
            MARKSVIRTUALDESK Reply #5, 18 years ago
            If the TV is not in the NewsListing template then all you need to do is include it via the hiddentvs argument. Can you please file a feature request with the following:

            If the user’s sort is not included in the template or hiddentvs parameter, automatically add it to hiddentvs.