Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog
================================================================================
- 1.3.1
- Added support for @-bindings (@CHUNK, @FILE, @SELECT) in Input Options Values field

- 1.3.0

- 1.2
- Checked/rewritten documentation
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ The format for the input option values is:

Creating a new line after the `##` is allowed.

##### @bindings

You can also use `@CHUNK`, `@SELECT` or `@FILE` bindings in the Input Option Values.
Example for the first dropdown:
`@CHUNK my_random_chunk_with_key_value_pairs`

For the child dropdown, you can combine multiple variants:
`Parentvalue1::@CHUNK key_values_for_Parentvalue1##Parentvalue2::plain==1||text==2||..##Parentvalue3::@SELECT name,id FROM mytable`

### Example 3: Individual processor usage

Create three Dynamic Dropdown template variables:
Expand Down
4 changes: 4 additions & 0 deletions core/components/dynamicdropdowntv/docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog
================================================================================
- 1.3.1
- Added support for @-bindings (@CHUNK, @FILE, @SELECT) in Input Options Values field

- 1.3.0

- 1.2
- Checked/rewritten documentation
Expand Down
12 changes: 11 additions & 1 deletion core/components/dynamicdropdowntv/docs/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,23 @@ Input Options | Input Option Values | 1::TEST1a==1a||TEST1a==1a##2::TES

The names `dynamicX` and `dynamicGroup` are just examples and could be changed.

This example will add two dropdown select TVs, where you can different values. After selecting a value in the first TV dynamic0, the dropdown select of the second TV dynamic1 will show related values. If you select again a value in the first TV dynamic0 all children of this Dynamic Dropdown TV (dynamic1) will be reseted.
This example will add two dropdown select TVs, where you can select different values. After selecting a value in the first TV dynamic0, the dropdown select of the second TV dynamic1 will show related values. If you select again a value in the first TV dynamic0 all children of this Dynamic Dropdown TV (dynamic1) will be reseted.

The format for the input option values is:
`Parentvalue::Key==Value||…||Key==Value##Parentvalue::Key==Value||…||Key==Value`

Creating a new line after the `##` is allowed.

####@bindings

You can also use `@CHUNK`, `@SELECT` or `@FILE` bindings in the Input Option Values.
Example for the first dropdown:
`@CHUNK my_random_chunk_with_key_value_pairs`

For the child dropdown, you can combine multiple variants:
`Parentvalue1::@CHUNK key_values_for_Parentvalue1##Parentvalue2::plain==1||text==2||..##Parentvalue3::@SELECT name,id FROM mytable`


Example 3: Individual processor usage
················································································

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,55 @@
$elementValues = array();
$elements = explode('##', $elements);
foreach ($elements as $element) {
$element = explode('::', trim($element));
// Check for any binding in element string
$regex = '/(.*)@(\w+)\W+(\w.+)/';

if(preg_match($regex,$element,$mtch)) {
$prefix = $mtch[1];
$type = $mtch[2]; //binding type
$val = $mtch[3]; //binding value string
$el;

switch($type) {
case 'CHUNK':
$el = $modx->parseChunk($val,array());
break;
case 'FILE':
$el = file_get_contents($modx->config['base_path'] . $val);
break;
case 'SELECT':
$sql = 'SELECT '. $val;

$c = new xPDOCriteria($modx,$sql); // connect to the MODX DB
$rows = array();
if ($c->stmt && $c->stmt->execute())
{
while ($row = $c->stmt->fetch(PDO::FETCH_ASSOC))
{
if(count($row) > 1) {
$rows[] = $row['name']."==".$row['id'];
} else {
$rows[] = $row['id'];
}
}
$el = implode('||',$rows);
break;
}
break;
/*
case 'INLINE':
$chunk = $modx->newObject('modChunk');
$chunk->setCacheable(false);
$elements = $chunk->process();
break;
*/
default:
break;
}
$element = $prefix . $el;
}

$element = explode('::', trim($element));
if (count($element) > 1) {
$key = trim($element[0]);
$values = explode('||', $element[1]);
Expand Down