Hi! Can anyone carefully explain some practical use or use case for the template properties? What are they thought for?
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?
-
☆ 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.
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.
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
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.