Increases the usefulness of template variables for the MODX Evolution content management framework
With this snippet the option values of a dropdown/listbox/check box/radio options template variable could be prefilled in the MODX backend. In the frontend a filter form control based on the option values of a template variable and the option text(s) corresponding to the current value(s) of a template variable could be shown.
- Upload the folder assets/snippets/quill in the corresponding folder in your installation
- Create a snippet called Quill and fill the snippet code with the content of the file install/assets/snippets/quill.tpl
The following snippet parameter could be used
Name | Description | Default |
---|---|---|
parent | Numeric ID or alias of parent document. Use with list mode | 0 |
len | Maximum length of list items title. Use with list mode | 50 |
depth | Depth of children to process. Use with list mode | 100 |
indent | Indent step for child items. Use with list mode | 3 |
default | Name of additional default item with value '0'. Use with list mode | - |
showPublishedOnly | Enables only published documents processing | 1 |
source | Switches source of items for list (documents | managers |
title | Fieldname to use as title in documents list. Use with list mode | page title |
tv | Name of template variable to use in [control] or [field] modes. (old param name is 'name') | |
value | Value of template variable to use in 'control' or 'field' modes, or range description in range mode (use 1-150 or a-z format). If not defined, returns existent template variable value | - |
sort | Attribute to sort list like 'pagetitle', 'menuindex', 'id'…. Use with list mode | menuindex |
sortdir | Directon of sort (asc / desc). Use with list mode and 'sort' parameter | ASC |
mode | Switches mode: list returns hierarchical tree of child document, 'control' returns manager control for template variable, 'field' returns the template variable option text instead of the template variable value | list |
With this example the selectable values of a template variable could be prefilled in the backend:
- Create a resource with the pagetitle
Currencies
and the aliascurrencies
- Create some child resources in
Currencies
resource and set their pagetitles toUS dollar
,Euro
,Yen
etc. and set their aliases tousd
,eur
,jpy
- Create a template variable with the name
currency
and the typeDropDown List Menu
and input option value@EVAL return $modx->runSnippet("Quill",array('parent'=>'currencies'));
- Bind this template variable with a template
- Ready. Edit/create a resource with this template
With this example a filter form control could be shown in the fronted:
- Create the resources and the template variable as in the first example
- Create a new resource and insert somewhere in the resource content the following snippet call
[[Quill? &mode=`control` &tv=`currency`]]
With this example the option text(s) corresponding to the current value(s) of a template variable could be shown in the fronted:
- Create the resources and the template variable as in the first example
- Create a new resource and insert somewhere in the resource content the following snippet call
[[Quill? &mode=`field` &tv=`currency`]]