This sounds promising.
Can I use this to do template switching on mobile detector as well?
Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
Security, security, security!
| Indonesian MODx Forum
| MODx Revo's cheatsheets
| MODx Evo's cheatsheets
Author of Easy 2 Gallery 1.4.x
, FileDownload R
, Upload To Users CMP
, Inherit Template TV
, Grid Class Key
Maintainter/contributor of Babel
Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky
if you need my help.
SwitchTemplate parses the templates itself with modx->getParser()->processElementTags and exits before the normal execution of the MODX parser, so maybe there are some glitches – i have tested it with getResource template chunks and FormIt calls to get different output for normal pages and Ajax results.
If you use SwitchTemplate to switch to another template, remember that it uses the TVs available in the original template.
[ed. note: Jako last edited this post 7 years, 1 month ago.]
Can SwitchTemplate be used also with different templates for differente resources?
From the doc, the property "Chunk/Template Name" seems unique.
This is not possible out of the box.
There are several ways thinkable to enhance the Plugin/CMP:
- Change that field into a grid (not that flexible)
- Use placeholders in that field content filled with the current resource content (and maybe template variables content).
What do you want to achieve?
I didn't understand the second way.
Any way to insert a "SwitchTemplate" template field inside the resource page (maybe in Settings tab) of the manager in which I can specify an alternative template?
All the settings of SwitchTemplate remains inside the actual SwitchTemplate settings page, but if a specific resource level setting is present then alternative template will be used instead of the general one.
Did I explained it well?
Second way is the same as you want.
The "Chunk/Template Name" field contains i.e. '[[*templatevar]]SwitchTpl' and the TV template var is filled for a resource with 'whatever'. Then the alternate template for that resource is changed to 'whateverSwitchTpl'. The other resources use the 'SwitchTpl' alternate template.
That would be very nice! I think this is the best solution...
What do you think about?
Hello, i have a problem.
I have installed SwitchTemplane and Wayfinder.
If i call page with main template, wayfinder shows resources with subcategories, like:
If i call page with switched template, wayfinder shows only first level of resouces, like:
Could you pleas look why is this happening?
What does the Wayfinder snippet in the switched template look like? Are the two snippet calls the same on both templates?