We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 35683
    • 2 Posts
    I want to manipulate a template variable before save.
    How can I access it ? (I think it should be in $scriptProperties, but I don’t know how to retrieve it)

    Thanks smiley
      • 36404
      • 307 Posts
      hi,

      the simple way to manipulate things on MODx events is to write your code in a plugin and then, set your plugin config to run on the event(s) you need it to

      have swing
        réfléchir avant d'agir
        • 35683
        • 2 Posts
        thanks for the answer smiley
        maybe I’m not asking it clear enough.
        I already wrote it as a plugin and tab on that OnDocFormSave event.
        I can access stuffs like $scriptProperties[’id’]
        but,I don’t know about how to access template variables sad
          • 36404
          • 307 Posts
          Hi,

          well, if in Evo, depending on what you want to do, you can access tv or tv output with MODx api $modx->getTemplateVar or $modx->getTemplateVarOutput
          in Revo, sorry, i don’t know, you’ll have to wait for a Revo guy to read this or dive into Revo Api smiley

          have swing
            réfléchir avant d'agir
            • 3749
            • 24,544 Posts
            The TVs are not in the $scriptProperties array. You need to get them from the DB.

            In Revo, the fastest way will be:

            $tvId = 12;
            $tv = $resource->getTVValue($tvIid);  // where $id is the ID of the TV
            


            If you need to alter the TV in the DB, however, it gets a little more complicated.

              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting