[[+content_image]]
A
A
alexalexes2021-01-18 10:57:03
MODX
alexalexes, 2021-01-18 10:57:03

How to pass your parameter to a chunk that acts as a template?

There is a snippet that generates the site menu:

[[pdoMenu ?
      &parents=`0`
      &level=`1`
      &tplOuter=`page_main_menu_other_tpl`
      &tpl=`page_main_menu_row_tpl`
      &tplHere=`page_main_menu_row_tpl`
    &outerClass=`main-menu`
      &firstClass=``
    &hereClass=`current`
    &lastClass=``
    &countChildren=`1`
    ]]

I would like to pass my_param parameter to the page_main_menu_other_tpl chunk and use the placeholder inside the chunk.
If I used a chunk separately, it would look like this: The chunk would
[[$page_main_menu_other_tpl ? my_param=`12345`]]
look like this:
<div>[[+my_param]]</div>
How to pass a similar parameter when using pdoMenu?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Anton Tarasov, 2021-01-18
@an-tar

What value are you passing?
Not a direct answer, but still - in a chunk, you can directly access the fields of the selected resources, or by ID to the fields of any other resources.
The following may also help you: pdoMenu inherits pdoTools https://docs.modx.pro/komponentyi/pdotools/snippet... common options , among which are

&tplCondition - The resource field from which the value will be obtained for selecting a chunk by condition in &conditionalTpls .
&tplOperator - An optional operator to compare the resource field in &tplCondition with an array of values ​​and chunks in &conditionalTpls.
&conditionalTpls - a JSON string with an array whose keys indicate what &tplCondition will be compared against , and the values ​​- chunks that will be used for output if the comparison is successful. The comparison operator is specified in &tplOperator . For operators of type isempty, you can use an array without keys.

With their help, you can also enter parameterization, however, if your parameter comes from a resource.
&tplCondition=`id`
  &tplOperator=`==`
  &conditionalTpls=`{"1":"имя чанка 1", "2":"имя чанка 2"}`

I
Igor, 2021-01-28
@ig0r74

Above the menu call
{$_modx->setPlaceholder('key', 'value')}
In the place where you need to get the value
{$_modx->getPlaceholder('key')}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question