We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10190
    • 187 Posts
    Hi,

    I have a template var (TV) in an modx 0.9.6.3 installation (upgrade is no option at the moment) which put's out a small textarea.

    The input is defined on many pages, so I don't like to overwrite it manually, and I would like to keep the TV's input to switch it back on later.

    But for some time (marketing project for some weeks), I'd like to output another text instead, which I would like to define only once.

    How could this be achieved?

    I thought about writing a small snippet, which overwrites the TV, but don't know how.

    But maybe this could be achieved easier?

    Any help is greatly appreciated.

    Cheers
    Frisco
      • 3749
      • 24,544 Posts
      If the text is the same for every usage, you could write a plugin attached to OnParseDocument and just use str_replace to replace the TV tag with whatever you want.

      I think this would do it (untested):

      <?php
      $content = $modx->resource->getContent();
      
      $content = str_replace('[[*MyTv]]', 'Something Else', $content);
      
      $modx->resource->setContent($content);
        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
        • 10190
        • 187 Posts
        Thanks BobRay, it's good to know how to do it the modx way.

        I solved it in the meantime like this:

        • duplicate tv
        • default value = new text
        • edit template to use new tv

        Thus I just have to edit the template (I could have used a copy as well) when I want to switch back to the first version.

        Sometimes the easiest things are the most difficult to get wink

        Cheers
        Frisco