??? Can this be done? ...
The Setup:
- Website X uses several different templates.
- Some of these templates are variations of each other, e.g. A1, A2, A3, B1, B2, C1, C2, etc.
- The resources for the "variants" all reside in the same template folder on the server.
I would like to have a nice, flexible shorthand for the path to each template folder, that doesn’t break chunks/snippets/etc when a page’s template is changed, or can be utilized across chunks/snippets intelligently.
I have been using Chunks just to have shortcuts, in linking to files: href="[[++base_url]]assets/templates/myTemplate/somefile" -- becomes --> href="[[$tpl]]somefile" This method saves a lot of typing, but a snippet has to be created for each separate path and used specifically... it’s not really dynamic.
Several bulbs went off when I saw property sets in action at the ModXpo (plug: everyone should try to go next year! My head is still swimming.) Property sets are, in a word, badass. I digress.
So, armed with new knowledge, I create templates A, B, C, etc., then add property ’tpl’ to each with the appropriate path for each. Now those paths are accessible in content and chunks ( [[+tpl]] ) and snippets ( $modx->getPlaceholder(’tpl’); ). That works great, and it ensures that the same snippet/chunk called from any page will pull from the correct folder based on the template setting of the page.
Here’s the twist... If I have templates A1, A2, A3, etc ... they all have the same path, I want to only have to set that variable in one place. I’m thinking this is the perfect place for a property set. So, I create a property set, assign it to all of the templates, and... doh! How do I tell the template to use that property set by default? I could just import the property set to the default set, but then if I have to update the path, that would still mean going back into each template and updating the property or reimporting the updated set.
I’m sure that this method could be used for something more useful than paths (let your imagination wander). I also suppose I could be going about this the completely wrong way. To me, though, it doesn’t fit in a TV because it’s above the resource level - and it’s above the template level, really, too. It’s below the system level, though, so it doesn’t seem to fit as a system setting. I suppose you could use a snippet to test the template setting somehow... but a property set just seems more elegant...