We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38926
    • 33 Posts
    I guess my question goes here since Im relativly new to using Modx wink

    I'm trying to figure out the nature of the Template Variables. When I read about them and look at them, they don't seem to offer anything that couldn't be done with a chunk with some snippets in it.

    Of course that could be reason for them: It allows you to skip the coding process. With my background as web developer it might be the reason that I cannot see the need for them, since I know how to make do without them.

    In case I am wrong, could someone tell me what TV's have to offer that sets them apart from chunks with snippets?
      • 3749
      • 24,544 Posts
      TVs have a value for a particular resource. Chunks don't and snippets don't unless you hardcode a test in them that looks at the ID of the current resource.

      There's also the convenience of the various types of TVs (@INHERIT, @FILE, @RESOURCE, richtext, date, image, etc.).


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 38926
        • 33 Posts
        I see. Didn't really get much smarter on what their real strength are, but thx anyways wink
          • 3749
          • 24,544 Posts
          Let me expand. wink

          If you need to store information related to a specific document (resource). You can put it in a TV and the specific value for that document will be saved. That TV can have a specific value for every different page. Suppose, for example, that you wanted a hit counter. There are several ways to do it, but one would be to create a TV called 'hits' and use a snippet or plugin to increment the value every time the page was visited. In the page template, you'd just put this:

          <p>Visits: [[*hits]]</p>


          Another use would be to record tags associated with each page for use in searching and sorting.

          The @INHERIT TV is particularly useful because the value for the current page will be inherited from the nearest ancestor in the tree with the value set (if no value is set for the current page).

          You could, for example, have a meta description HTML tag in the page template containing a snippet tag that used the 'description' field for the page but fell back to a 'Description' TV if the 'description' field was empty. If the Description TV default value was set to @INHERIT, you could set default descriptions in a container resource and all it's children would inherit that description, to be used if their 'description' fields were empty.

          Of course you could do any of this with a snippet (though having tagged pages would be fairly challenging and probably inconvenient for the user). Using TVs is often much more convenient than doing it with a snippet. That said, if things get complex, the snippet version will often be faster.


          ---------------------------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
          MODX info for everyone: http://bobsguides.com/modx.html
            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
            • 38926
            • 33 Posts
            Does that mean that TV's have persistent data? Are they automatically linked with the database?
              • 3749
              • 24,544 Posts
              Yes, their values for each resource are stored in a separate table in the DB.


              ---------------------------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
              MODX info for everyone: http://bobsguides.com/modx.html
                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
                • 38945
                • 3 Posts
                Moving my Site to a New Server , getting error " Log into the manager on the new server to verify that it works. Upon entry, my experience:

                Could not find action file at: /path/to/manager/controllers/default/welcome.php


                I updated all the files

                config.core.php
                /connectors/config.core.php
                /manager/config.core.php

                and

                In Databse workspaces path name also.


                Still getting error
                Could not find action file at: /path/to/manager/controllers/default/welcome.php


                please anyone can help me in this.

                Thank You.

                Regards
                Sharma


                  • 38926
                  • 33 Posts
                  Thx for the answer then. Guess I can find a use for TV's here and there with some more experience with modx then wink
                    • 3749
                    • 24,544 Posts
                    @parthweb What version of MODX are we talking about?

                    Did you do an upgrade install/setup after moving things? That's necessary.


                    ---------------------------------------------------------------------------------------------------------------
                    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
                    MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 7 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
                      • 37840
                      • 33 Posts
                      Hey guys, I think I should post here since im just a n00b....its a quick one:

                      When you using galleries, is there a way I can call from all the images in the gallery and sort by "date added" i cant see the option in the property "sort", i want something like this;

                      [[!Gallery? &album=`1,2,3,4,5` &sort=`date_created` &dir=`desc` &limit=`3`]]


                      So grab 3 images from all albums sorted by date created descending.

                      Does this make sense, please help. I want to add a "Latest Photos" section