<![CDATA[ Support/Comments for SwitchTemplate 1.0.0 - MODX Community Forums]]> https://forums.modx.com/thread/?thread=94372 <![CDATA[Re: Support/Comments for SwitchTemplate 1.0.0]]> https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=4#dis-post-549821 Jako Apr 02, 2017, 09:27 AM https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=4#dis-post-549821 <![CDATA[Re: Support/Comments for SwitchTemplate 1.0.0]]> https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=4#dis-post-549620
Something like (line 134)
// stop, if resource id is not in include list or in exclude list
if ((count($include) && (!in_array($resourceId, $include))) ||
(count($exclude) && (in_array($resourceId, $exclude))) ||
!($this->modx->resource->get('template')>0) // added!
) {
return null;
}

in core/components/switchtemplate/model/switchtemplate/switchtemplate.class.php]]>
the-city Mar 23, 2017, 09:37 AM https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=4#dis-post-549620
<![CDATA[Re: Support/Comments for SwitchTemplate 1.0.0]]> https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=4#dis-post-543132 https://github.com/Jako/SwitchTemplate/blob/master/core/components/switchtemplate/elements/plugins/switchtemplate.plugin.php#L29-L36 Otherwise the switched result would be saved in the default resource cache.

So if you want to switch the template in a Snippet, you have to get the current resource, get the template you want to parse this resource in, parse this template, output the result and exit after (that way the default MODX parsing and caching process is not executed).

https://github.com/Jako/SwitchTemplate/blob/master/core/components/switchtemplate/model/switchtemplate/switchtemplate.class.php#L179-L250 is the code for parsing the switched template.]]>
Jako Jul 08, 2016, 05:28 AM https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=4#dis-post-543132
<![CDATA[Re: Support/Comments for SwitchTemplate 1.0.0]]> https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=4#dis-post-543112
I've installed SwitchTemplate. I need to be able to switch the default template for a group of images to another template if there is only one image in the group.

Is there a way to add SwitchTemplate in a snippet? I have

$count = count($modx->getChildIds($parentTvValue,1));

if ($count == 1) { Code to switch template }

what code do I need to use?]]>
fgarydc Jul 07, 2016, 10:33 AM https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=4#dis-post-543112
<![CDATA[Re: Support/Comments for SwitchTemplate 1.0.0]]> https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=4#dis-post-533751

In that case good old JavaScript did the job as well, not as "stable" as preprocessing the data but better than giving up on SwitchTemplate.]]>
just_nico Oct 27, 2015, 02:30 PM https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=4#dis-post-533751
<![CDATA[Re: Support/Comments for SwitchTemplate 1.0.0]]> https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=3#dis-post-533522 Jako Oct 22, 2015, 09:26 AM https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=3#dis-post-533522 <![CDATA[Re: Support/Comments for SwitchTemplate 1.0.0]]> https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=3#dis-post-533336
With OnLoadWebPageCache I haven't had any success either; it works for "normal" sites to e.g. simply attach a text, not for switchTemplate. Like with
$src = &$modx->event->params['resource']->_content;
$src = $src . 'testing things';
$modx->log(modX::LOG_LEVEL_ERROR, 'OnLoadWebPageCache successful');

The event is active and firing (always 2 times for switch template, once for "normal" as my log shows). Priority is 1 for my plugin, 2 for switchtemplate.

SwitchTemplate caching is true, inside as content-to-change I have some migxLoops (cached).


]]>
just_nico Oct 18, 2015, 01:02 PM https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=3#dis-post-533336
<![CDATA[Re: Support/Comments for SwitchTemplate 1.0.0]]> https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=3#dis-post-526529 Jako Jun 06, 2015, 01:12 PM https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=3#dis-post-526529 <![CDATA[Re: Support/Comments for SwitchTemplate 1.0.0]]> https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=3#dis-post-526491 first: great plugin! Comes in handy quite often. Maybe you have a quick idea or even solution for this.

I am running into the problem that I can't register a CSS file (via snippet call) when using switchTemplate. The setup is that I have a code for listing some elements and a detailcode for a detail view for each element. Switching between the templates works great. For test purposes I register the CSS file in a chunk that is used on every page (page head). Injecting the CSS works without problem on the listing and every other site. But NOT on the detail page.

Every other snippet runs smooth on the detail view, e.g. echoing the current user etc. Just everything with $modx->registerClient* doesn't seem to be executed. No matter if caching is on or off.
]]>
just_nico Jun 05, 2015, 01:17 PM https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=3#dis-post-526491
<![CDATA[Re: Support/Comments for SwitchTemplate 1.0.0]]> https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=3#dis-post-522786 I'll check it soon and I'll give you my feedback.

ROb]]>
impiastro Mar 17, 2015, 08:33 AM https://forums.modx.com/thread/94372/support-comments-for-switchtemplate-1-0-0?page=3#dis-post-522786