Hi Jako.
This sounds promising.
Can I use this to do template switching on mobile detector as well?
Rico
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!
www.virtudraft.com
Security, security, security! |
Indonesian MODx Forum |
MODx Revo's cheatsheets |
MODx Evo's cheatsheets
Author of
Easy 2 Gallery 1.4.x,
PHPTidy,
spieFeed,
FileDownload R,
Upload To Users CMP,
Inherit Template TV,
LexRating,
ExerPlan,
Lingua,
virtuNewsletter,
Grid Class Key,
SmartTag,
prevNext
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.
Should be possible. If the mobile detector is a PHP based plugin, this plugin has to be called before the SwitchTemplate plugin is executed (it runs on OnLoadWebPageCache/OnLoadWebDocument) and it has to set the $_REQUEST key that triggers switchtemplate (default key is 'mode') – it could also set a cookie, but that is regarded only with the next load of the page. If the mobile detector is javascript based, the detector should redirect to the page with a get parameter or with a cookie.
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 9 years, 6 months ago.]
-
- 10 Posts
Can SwitchTemplate be used also with different templates for differente resources?
From the doc, the property "Chunk/Template Name" seems unique.
Thanks!
ROb
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?
-
- 10 Posts
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?
Thanks Jako!
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.
-
- 10 Posts
That would be very nice! I think this is the best solution...
What do you think about?
-
- 4 Posts
Hello, i have a problem.
I have installed SwitchTemplane and Wayfinder.
If i call page with main template, wayfinder shows resources with subcategories, like:
Page1
--Page11
--Page12
Page2
If i call page with switched template, wayfinder shows only first level of resouces, like:
Page1
Page2
modx-2.3.2
switchtemplate-1.0.1
wayfinder-2.3.3
cache off
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?