We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3349
    • 126 Posts
    Hello

    Im a Modx newbie and wondered if the following is possible and if it is how is it done.

    I have a simple Start date TV that sets thw start date of an event. Im also using the ListIndexer snippet to list my events on an events page.

    What i want to know is can I call my StartDate TV from inside the ListIndexer snippet so it can display start date of the event too?

    The line i’d be updating n the snippet is this one:

    $output .= ’<a href="[~’.$recentRecord[’id’].’~]" title="’.strip_tags($recentRecord[’pagetitle’]).’">’.$recentRecord[’pagetitle’].’</a> ’;

    Thanks, I hope some can help, I’m not sure if and how it can be done

    bS
      • 22303 MODX Staff
      • 10,725 Posts
      You’ll need to make use of the getTemplateVarOutput() function.
        • 3349
        • 126 Posts
        Thanks for the reply...

        This is where I get lost! I’ve had look at this function but am not quite sure how/where to implement it?

        I have a simple text TV that takes date as a string called StartDate.

        What do I need to do with the function bit?

        Excuse my ignorance...

        bS
          • 33372
          • 1,611 Posts
          You’ll want to first get the TV output using something like this:

          $tvStartDate=$modx->getTemplateVarOutput(’StartDate’,$recentRecord[’id’]);

          The getTemplateVarOutput function returns an array, so you should then use $tvStartDate[’StartDate’] wherever you want to place that output (and depending upon how you’ve stored your date info, you may also need to use strtotime() or otherwise format it for your purposes).
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 3349
            • 126 Posts
            It works a treat!

            Thankyou for allowing me to extract valuable information from your brain!

            bS

            BTW: Can’t believe I never stumbled across ModX before now, I have been using Etomite for a good while now but the flexibility of ModX is astounding in comparison and with the confidence of knowing that the forum is there for help and support, I’m now fully converted!

            Cheers