Hello,
I’m trying to get some PrevNext navigation to work on all the childpages of a certain folder(category); I’was thinking of creating a @INHERIT TV so I could have an input field with e.g. the following: ’sortBy=createdon||sortHow=DESC||displayTitle=false’; this would be the parameters I would need to pass to the PrevNext script.
What I’m struggling with at the moment is how to convert a string like that to an parameter array so I could pass it to the snippet:
here is a start:
$tv = $modx->getTemplateVarOutput('tvPrevNext', $modx->documentIdentifier);
$str = $tv['tvPrevNext'];
....
return $modx->runSnippet('PrevNext',$param);
I guess explode(’||’,$str) would give me a first array but how do I go from there?
Hope somebody can help.
P.S. if somebody has a better idea of how to do this, please let me know as well.
Thank you guys
Thank you in advance for your input.
Maybe, I’m a little closer - this is what I have and it seems that I’m able to set the parameters:
$tv = $modx->getTemplateVarOutput('tvPrevNext', $modx->documentIdentifier);
$array = explode('|', $tv['tvPrevNext']);
$param = array();
foreach ($array as $key => $value) {
$arr = explode('=', $value);
$param[$arr[0]] = $arr[1];
}
return $modx->runSnippet('PrevNext',$param);
However, I guess there is an easier way?!