Search code examples
phpmodxmodx-revolutionget-request

modx send and get via url (get request) variable


I need to form a link with some parameters in it like this:

<a href="[[~[[*id]]? &sorting=`Data.price`]]">

and then I want to get the parameters in my getPage snippet like this:

[[!getPage:default=`Ничего не найдено`?
    &element=`msProducts`
    &parents=`[[*id]]`
    &sortby=`[[*sorting]]`
    &sortdir=`ASC`
]]

How to accomplish this task properly? How to send and then get user's parameters?


Solution

  • Use setPlaceholders extra - https://github.com/oo12/setPlaceholders

    [[!setPlaceholders? &ph=`sorting == get.sorting`]]
    

    and then use [[+sorting]] it in your getPage construction

    [[!getPage:default=`Ничего не найдено`?
        &element=`msProducts`
        &parents=`[[*id]]`
        &sortby=`[[+sorting]]`
        &sortdir=`ASC`
    ]]