Answer the question
In order to leave comments, you need to log in
[[+content_image]]
Why does pdoPage reset the context when switching to another news page? How to fix it?
There is a news page. It has pdoPage. Here is the challenge:
[[!pdoPage?
&elementClass=`modSnippet`
&element=`pdoResources`
&parents=`2`
&tpl=`allnewsItem`
&includeTVs=`newsImg, newsDate`
&prepareTVs=`1`
&depth=`0`
&limit=`6`
&includeContent=`1`
&ajax=`1`
&ajaxMode=`default`
&pageVarKey=`page`
&pageNavVar=`page.nav`
]]
<?php
switch($context = $modx->context->key) {
case 'web':
$result = 'Привет';
break;
case 'en':
$result = 'Hello';
break;
}
return $result;
Answer the question
In order to leave comments, you need to log in
pdoPage supports the &context parameter common to all snippets from the pdoTools package, pass the context there from the system parameter like this:
[[!pdoPage?
&elementClass=`modSnippet`
&element=`pdoResources`
&parents=`2`
&tpl=`allnewsItem`
&includeTVs=`newsImg, newsDate`
&prepareTVs=`1`
&depth=`0`
&limit=`6`
&includeContent=`1`
&context=`web`
&ajax=`1`
&ajaxMode=`default`
&pageVarKey=`page`
&pageNavVar=`page.nav`
]]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question