We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22446
    • 181 Posts
    Currently running modx 2.1.3-pl

    I have created a template variable called right column. The purpose of this template variable is to display the content in the right column. I setup the default input to be a line of code to retrieve rss feeds. I updated my rss feeds to retrieve multiple feeds.

    The pages I have already created don't update using the default. Is there a way to update all the resources that use the default input on the template variable?
    • If they are using the default there should be no issue; if you have set specific values for each Resource to which the TV is accessible, then you will need to reset the Resource-specific value to the default.
        • 22446
        • 181 Posts
        That is just it. I have made changes to the default input in the TV. I copy it and paste it into the homepage.

        The default and homepage now have the same thing entered into the TV. If I make a change to the default input, it doesn't change on the homepage. Why not?
          • 3749
          • 24,544 Posts
          Every page has its own value for a TV. It the page value matches the default value, the page value is not set (because the default value will be used when it's empty).

          If you manually enter the value of a TV for a specific page, that's the value for that page from then on, regardless of what you do to the TV. The only exceptions are changing the template or deleting the TV.

          Because of the way it works, it's really best to think of the TV's default value as only applying when you create a new page.

          That said, it often works well to set the TV to:

          @INHERIT some_value


          That way it will inherit any page value set in an ancestor but get "some_value" if no ancestor has a page value for the TV.
            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
            • 22446
            • 181 Posts
            Thanks bob. Is there a way that I can set a value on the page with the TV that will reference the default value?
              • 3749
              • 24,544 Posts
              If you don't set a value on the page at all, the default value should be used.

              You could also create a snippet that would pull the default value. That would save you from having to edit all the values (replace 12 with the ID of the TV).

              [[!GetTvDefault? &tv=`12`]]


              <?php 
              /* GetTvDefault snippet */
              $tvObj = $modx->getObject('modTemplateVar', $scriptProperties['tv']);
              
              if ($tvObj) {
                  return $tvObj->get('default_text');
              } else {
                 return 'TV Not Found';
              }
               


              I think this would also work as a custom modifier, though it would be a little slower:

              [[*MyTv:GetTvDefault]]


              <?php 
              /* GetTvDefault custom output modifier */
              $tvObj = $modx->getObject('modTemplateVar', array('name' => $scriptProperties['name']));
              
              if ($tvObj) {
                 $output =  $tvObj->get('default_text');
              } else {
                 $output = 'TV not found';
              }
                return $output;
               


              [ed. note: BobRay last edited this post 12 years, 6 months ago.]
                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
                • 22446
                • 181 Posts
                BobRay,

                The snippet works awesome!!! Thank you so much for your help. This will certainly solve a lot of issues with similarities throughout my site.
                  • 3749
                  • 24,544 Posts
                  I'm glad it worked. Thanks for reporting back. smiley
                    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