-
- 52 Posts
Hi,
I need to execute a snippet only for specific page language and cannot figure out how to do it
Or may be this is not possible.
There is a snippet like this:
[[ConditionalRedirect? &variable=`<tvar>` &condition=`<value>`]]
the snippet functionality is something like:
if (ValueOfTV == ValueOfCondition) {header( ’Location: ’ . $url , TRUE, 303);
So far so good. This construct is in general working.
But if I use it like this:
- I have multilingual variable ( var_bg and var_en)
- var_bg=1 var_en=0
- I call the snippet like this [[ConditionalRedirect? &variable=`var_(yams_id)` &condition=`0`]]
- The snippet can be in a template, or in in the content (for each language)
The expectation is to have the redirect if the page language is "en"
The reality is that the redirect happens always.
I’m not an expert in yams or in modx, so I don’t know the internals of parsing and executing the snippets,
but from the behavior my conclusion is that the page is rendered (processed) in all available languages independent of the current.
Is it possible to avoid this behavior and to execute the snippet only for current language?
-
- 805 Posts
I’ll have to check to be sure, but I think that uncacheable snippet calls are only executed for the served language, whereas cacheable snippet calls are executed and cached for all languages. So, please try making your snippet call uncacheable (which you need anyway) and see if that makes a difference.