A
A
artr_lr2017-02-27 12:34:00
MODX
artr_lr, 2017-02-27 12:34:00

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-код

Where $two-button and $one-button are chunks with html-code blank, if parameter = 0 then output nothing. As a result, when passing a parameter equal to 1, nothing is displayed ... What could be the matter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
display: block, 2017-02-27
@artr_lr

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 question

Ask a Question

731 491 924 answers to any question