Hello Guys,
I’m confuse implement placeholder and chunk in snippets.
What I want to is:
Expected Output:
<li><a href="#">Option 1</a></li>
<li><a href="#">Option 2</a></li>
<li><a href="#">Option 3</a></li>
<li><a href="#">Option 4</a></li>
=========
On TPL at chunk
<li><a href="#">[+optionvalue+]</a></li>
=========
Here is the snippets
Loading Template Variable Option Value into Array
<?php
$tvname = isset($tvname) ? $tvname : ’’;
$valueTpl = isset($valueTpl) ? $valueTpl : ’’;
$result = $modx->db->select("elements", "modx_site_tmplvars", "name = ’". $tvname . "’ ");
while($row = $modx->db->getRow($result)) {
$value_string = $row[’elements’];
}
$value = explode(’||’,$value_string);
foreach($value as $key => $isi){
$modx->setPlaceholder(’optionvalue’, $isi);
print $isi;
print $modx->getChunk($valueTpl);
}
?>
in the bold text,
the result for print $modx->getChunk($valueTpl); is
<li><a href="#">Option 4</a></li>
<li><a href="#">Option 4</a></li>
<li><a href="#">Option 4</a></li>
<li><a href="#">Option 4</a></li>
the result for print $isi is
Option 1
Option 2
Option 3
Option 4
The placeholder sent result only the last value of array. How to get chuck filled with looping setplaceholder properly?
I’m newbie for placeholder, if you have some advice will be great
Regards
b4ndeng