We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3342
    • 1 Posts
    Hi ... I’m a hack ... (let’s get that out of the way shall we!)

    Has anyone updated the value of a Template Variable dynamically?

    Example ... click submit button ... call a snippet ... snippet updates the Template Variable ... page reloads ... whole new ball game.

    Am I drunk ... Yes. Do I need help ... Yes!

    Thank you in advance if anyone has any ideas.
      • 7231
      • 4,205 Posts
      I don’t know if anyone has done it but I am sure it can be done. You would want to use the docmanager API and use a snippet. Remember that a snippet is basically php code and a tv is just a field on a database, so basically you can do anything with it that you would be able to do in any other scenario.

      Learn more about the Docmanager API here: http://modxcms.com/forums/index.php/topic,5983.0.html
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 21257 MODX Staff
        • 730 Posts
        I hacked around quite a few months back in order to create a form where you could edit a document’s template variables in the front end.
        It was basically a reworking of the NewsEditor snippet, plus I nicked a bunch of code from the manager side to get the tv field rendering to come out properly.
        I only implemented it on one site, so it’s not all nice and neatly packaged up. And with 0.9.7 on the horizon, I’m not sure that my approach to the problem is worth pursuing as a general solution.
        Still, if anyone’s interested I could sketch it out in a bit more detail.
          Mike Schell
          Lead Developer, MODX Cloud
          Email: [email protected]
          GitHub: https://github.com/netProphET/
          Twitter: @mkschell
          • 7231
          • 4,205 Posts
          Still, if anyone’s interested I could sketch it out in a bit more detail.
          That would be great if you have the time grin
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]