We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24495
    • 407 Posts
    I have a TV assigned to a template:
    input type: date, display type: unixtime
    input option and default the same @eval:
    @EVAL return $modx->runSnippet('firstDate');



    The snippet returns a date collected from another document’s date TV. I tried some formatting for the output

    • as unix timestamp: 1217102289
    • formatted via strftime("%d-%m-%Y %H:%M:%S", $datevar): 26-07-2008 21:58:09

    The result in edit mode of a document using the template with assigned TV is: "(not set)"


    Using 0.9.6.1p2 on
    PHP Version 5.2.6, Linux, Apache/2.2, MySQL 5.0.32, UTF-8
    PHx, ManagerManager (disabled or not: same result)

    Why the TV is unset?
    Putting [*dateTvName*] anywhere in the template source code for a visual output at rendered page give back the result of the snippet. (Gives only back an output if the TV IS NOT display type unixtime).
    But using the TV in snippets like Ditto (as sortBy parameter) for other pages failes. And this is my problem: I need this value for sorting Ditto output at start page.

    Is the error in the TV, in MODx or in front of the monitor embarrassed

    ADDITIONAL: debug mode at start page says that the TV is "0". All other output seen in debug is ok.
    Tried other versions of @eval any (other) snippet outputs as various input types. The result is always the @eval code as text and NEVER the snippet’s return value.
    Seems that the TV never gets the snippet’s output. What’s wrong? Need help please.
      • 30223
      • 1,010 Posts
      I’ve never used @ bindings with a date TV so I looked through the code and it appears @ binding is simply not possible with date TV’s (unless my comprehension level has dropped dramatically tonight).

      It seems you’re in a pickle and to be honest I can’t really think of a workaround just now.
        • 24495
        • 407 Posts
        Sorry, but I need a solution for my problem. I need a sortBy parameter for a ditto call from a grandchild document (described here: http://modxcms.com/forums/index.php/topic,27265.msg165637.html).

        Let me explain: I have the travel pages with travel dates. Each date is set by TVs for start and end in child doc. The travel page prints the dates by a Ditto call retrieving the TVs in the child docs.
        Now I want to list teasers of all travels on the home page containing some content of each travel plus the dates. That works ok. For a logical order of the travels I wish to sort them by the first date of each travel. I can get this first date by a snippet and my idea was to put this date into a TV of the travel page. Then the ditto call at home page should take this TV value as sortBy parameter. But the binding is empty.

        Now I’m searching for another way to get a sort parameter depending on the date order in all child docs of travel pages. Tried to put the unixtime as a number into the TV type number (via @binding). Also failed. I need a numerial or date value which is sortable by Ditto.
          • 24495
          • 407 Posts
          Maybe with a date TV it doesn’t work but it should work generally: http://modxcms.com/forums/index.php/topic,11315.msg76426.html#msg76426
          Or not?

          Technical question from PHP newbie: What I get from a snippet that reads a date TV and returns the unixtime-like date. It is a numerical string or not? Can I eval this string as a number or as a text into another TV?