Answer the question
In order to leave comments, you need to log in
Processing a condition in a chunk?
There is an element on the site, for example, a header) and let's say in the main template I need to have 2 buttons in the section, on the other page there is one, on some other there was no other.
So, logically, we drive this section into a chunk, and in the template we prescribe a parameter for this chunk. Depending on the parameter, we display the "subchunk"...
In the main template, I write the chunk and pass the parameter:
In the top-banner chunk, I write the following
// тут какой-то html-код
// тут какой-то html-код
Answer the question
In order to leave comments, you need to log in
And with param=2, is something output?
You can make nested conditions:
Or snippet:
switch ($param) {
case '1':
$num = 'two';
break;
case '2':
$num = 'one';
break;
default:
return;
}
return $modx->getChunk($num."-button");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question