From form to pdoresources


I’m thinking about a solution for the following problem: I have several documents in a parent folder. These documents have various properties that are realized using TVs.
I would like to create a form in which the user can make various settings. After the form has been sent, the corresponding documents should then be displayed using pdoResources.

But how do I send the settings made in the form to pdoResources?
Does anyone have an approach?
So pdoResources should get the settings tvFilters and so on from this form.

Create your form and collect the ids (checkboxes).

You FormItRetriever - FormIt | MODX Documentation to get the submitted ids.

I would just test it first to display the list, then you should be able to past the ids to pdoResources.

1 Like

The settings from from form are available in the PHP super globals $_POST, $_GET, $_REQUEST.
You can read the values from these super globals in a snippet and sanitize them.

Version 1: With the submitted values you create the &tvFilters string (or the condition for the &where property) in your snippet and return the value directly.


Version 2: You read the submitted values in a snippet and create placeholders ($modx->setPlaceholder('myPlaceholder', $some_value);) that are used later in the pdoResources call.



Version 3: You read the submitted values in a snippet and directly execute pdoResources in the snippet with $modx->runSnippet(...).

return $modx->runSnippet('pdoResources', [
    'tvFilters' => $my_filter_string,
    'tpl' => 'myTemplate', ...

Make sure to call these snippets (and placeholders) uncached.

1 Like

Thanks a lot, that are both very good approaches that will help me a lot.