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

    I would like to know, if possible, how to get the value of a template variable for a specific document.
    For example, I have created a TV called menuTitle_en and I want to get its value from another document.
    Is there a syntax like [*menuTitle_en*:docId] ? (where docId is the id of the document that I want to get the TV value)

    Thank you in advance
      • 22303 MODX Staff
      • 10,725 Posts
      You can use the GetField snippet for this purpose I believe; or roll your own using the API functions.
        • 15083
        • 697 Posts
        Good way of pulling a list of TV values for a doc:

        $tvPr = $modx->getTemplateVarOutput(array(’name_of_tv’),$docid=100,$published=1);
        // If doc is not published...
        if (empty($tvPr))
        {
        $tvPr = $modx->getTemplateVarOutput(array(’name_of_tv’),$docid=100,$published=0);
        }

        Access it:

        $tvPr["name_of_tv"];

        This help?
          • 12433
          • 16 Posts
          Although I eventually wrote my own piece of code in order to do the job, this worked also...

          Thank both of you for your assistance wink