We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24495
    • 407 Posts
    Need a push to the right way: I have a site for a travel organizer. Each detailed travel description has sub-documents for each travel date containing TVs for start and end date of the travel. Example structure:
    travel overview page

    • travel 1[list]
      [li]date 1 (containing start_tv and end_tv)
    • date 2 (containing start_tv and end_tv)
    [/li]
    [li]travel 2

    • date 1 (containing start_tv and end_tv)
    • date 2 (containing start_tv and end_tv)
    [/li]
    [li]travel ...[/li]
    [/list]
    Now I want "ditto" (nice verb grin ) all travel at overview page sorted by the start_tv in grandchild docs. Thanks for ideas.
      • 24495
      • 407 Posts
      ping ...

      Isn’t there a way or am I blind to find a solution? Searched the forum awhile but doesn’t found an answer.

      Is sortBy in Ditto only possible with fields of documents to be sorted? Or can I use TV values of other (child) documents anyway?
        • 24495
        • 407 Posts
        Next try, further step:
        Now I have a snippet [tt][[firstDate]][/tt] fetching the content of the start_tv building an output as a unix timestamp (e.g. 1216504810 for date of 20.07.08 ...).

        In the template of parent travel documents I have a date TV (sortKrit) as unixtime widget with optional and default values:
        @EVAL global $modx; return $modx->runSnippet('firstDate');


        Putting the TV into the template source as [tt][*sortKrit*][/tt] the rendered page shows the value 1216504810.

        Looking into edit mode of a travel document the TV [tt][*sortKrit*][/tt] is "not set".

        Therefore Ditto sorting at overview page fails, value of sortKrit is empty. Ditto call:
        [[Ditto? &parents=`191` &tpl=`allereisenStart` &display=`all` &dateSource=`sortKrit` &sortBy=`sortKrit` sortDir=`ASC`]]

        Why? What’s wrong with this code? Seems that I’m spinning around huh