I have two contexts and I use a snippet to get the current context. The snippet is working properly, but when I use it in a getResources
call, its not passing the snippet value.
[[getResources?
&parents=`0`
&limit=`10`
&depth=`0`
&tvFilters=`cb_show_in_top_bar_menu==1`
&includeTVs=`1`
&includeTVList=`cb_show_in_top_bar_menu,cb_hash_link_menu`
&tpl=`chk-top-menu-item`
&sortdir=`ASC`
&sortby=`menuindex`
&context=`[[!context]]`
]]
The context snippet is
return $modx->context->key;
Can someone tell me how can this be done.
What you have is exactly right, probably something to do with getResources. ~ try calling it uncached. if not, try setting your context key as a context setting so you can call it as [[++context_key]] or in your context snippet set it as a placeholder:
[[!context]]
[[!getResources?
&parents=`0`
...
&sortby=`menuindex`
&context=`[[+context_key]]`
]]
!context
$key = $modx->context->key;
$modx->setPlaceholder('context_key', $key);
return;