We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28673
    • 178 Posts
    Hi! Can anyone carefully explain some practical use or use case for the template properties? What are they thought for?
      • 22303 MODX Staff
      • 10,725 Posts
      Since you cannot apply property sets or call a template with a MODX tag, the only practical uses I’ve found for them so far are:

      • To simply provide template-specific property values that can be referenced in the template, e.g. [[+myTemplateAssets]] or similar.
      • You can use the same property on multiple templates to abstract a section in the template, e.g. [[+topOfTemplate]] and then provide the template-specific variations in the default property value for each template.

      I’m sure others can imagine other specific uses, but they inherit the property behavior that all Elements have simply because they are Elements. There was no specific intended usage.
        • 28673
        • 178 Posts
        Mmm.

        So, currently, I have 2 tv: css_path and js_path, where I write down page-specific css and js files path that I then retrieve with a simple snippet placed in a ’head’ chunk, common to several templates. This for trying not to have 1 template per page, where the only things that change are css and js..

        Well, there’s a problem: I don’t want my client to worry about setting specific css and js for every product page, when he creates them. So, the first way to avoid this, is to make 1 step back and just use a specific ’product’ template. That template will be identical to other site templates, eccept for a ’product_head’ chunk.

        ok. I was wondering: would it be ’formally’ correct to set a couple of template properties (css_path and js_path) on the ’product’ template? Just to avoid having a ’product_head’ chunk. This maybe would be a copromise between the tv way and the template+chunk way. I still have to create specific templates, but don’t have to use specific chunks.

        What do you think about this?


          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: stratboy at Feb 01, 2011, 01:40 AM

          So, currently, I have 2 tv: css_path and js_path, where I write down page-specific css and js files path that I then retrieve with a simple snippet placed in a ’head’ chunk, common to several templates. This for trying not to have 1 template per page, where the only things that change are css and js..

          Well, there’s a problem: I don’t want my client to worry about setting specific css and js for every product page, when he creates them. So, the first way to avoid this, is to make 1 step back and just use a specific ’product’ template. That template will be identical to other site templates, eccept for a ’product_head’ chunk.

          ok. I was wondering: would it be ’formally’ correct to set a couple of template properties (css_path and js_path) on the ’product’ template? Just to avoid having a ’product_head’ chunk. This maybe would be a copromise between the tv way and the template+chunk way. I still have to create specific templates, but don’t have to use specific chunks.

          What do you think about this?
          Definitely not a place to use Template Properties. This is what Template Variables are for.
            • 28673
            • 178 Posts

            Definitely not a place to use Template Properties. This is what Template Variables are for.

            Mmm, ok. so what do you think should be the right way to solve my problem (have different css js per page without duplicate chunks or templates AND without force my client to edit css and js paths)?




              • 18373 ☆ A M B ☆
              • 3,141 Posts
              You should be able to limit the template variables your client’s accoutn can see by limiting access to element groups/categories.
                Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                • 3749
                • 24,544 Posts
                You shouldn’t really need a snippet for this if I’m understanding you.

                Just put the paths in the TVs and use tags in the <head>:

                <link rel="stylesheet" type="text/css" href="[[*css_path]]" />


                Then, as Mark H. says, hide the TVs from the client with Form Customization rules.
                  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
                  • 28215
                  • 4,149 Posts
                  I’ve used Template properties to store paths, such as Template-specific paths to CSS/JS files before. I think that’s a valid approach.

                  You can also use it to give more information *about* the Template you’re using - say, "Interior" or "Blog Post", etc. Just thoughts.
                    shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                    • 3749
                    • 24,544 Posts
                    I also wouldn’t say you should never use Template properties that way. The TVs would be a little slower.

                    OTOH, with TVs, you have the option to use @INHERIT and then modify them on specific pages if they need a different CSS or JS path than the one for the template.
                      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
                      • 28673
                      • 178 Posts
                      @ Mark H. & BobRay (first take): that’s exactly what I made, that’s exactly what I want avoid and I’m trying to ask now. I do not want to use tv, because then I must hide them from my clients. But, say I’ve got products sheets: how do my clients add the specific css and js if the tv are hidden for them? No, what I’d like is a solution that let me do not use tv and still d not build a template for every single page. Above, I depicted a couple of ways.

                      @splittingred: thank you smiley You’re a modx dev so I trust you. My way was not too wrong then. smiley

                      @BobRay (second take): @INHERIT could be interesting smiley thank you