I’m having a problem which is very frustrating because I can code ok but I’m fairly new to modx and the logic is just a bit different and therefore confusing for me.
I want to make a sort of panels in my layout. The user must have the ability to add panels so therefore I am writing now a snippet that implements a chunk for every panel.
The snippet call:
[!panel? &titel=`Header Text` &kolom=`1`!]
So far so good. Then I want that the user can edit the content of these panels in the front-end-editor (Quickedit I believe it’s called?). So I probably have to attach TV’s to every panel. My solution is to have a counter in the snippet and with that the reference to the TV is changing like "reference1", "reference2", "reference3", and so on. This reference is then placed into the placeholder.
This doesn’t seem to work. What is the strategy here? Does someone has a hint for me in what direction I have to look?
The snippet code: (a bit messy because all the weird things I’ve tried)
<?php
if(function_exists(panelFunc)) {
++$kloten;
} else {
$kloten = 1;
function panelFunc() {
}
panelFunc();
}
$ouput = '';
$panelKolom = 0;
$pan_str_K = '';
$pk = '';
$panelKolom = $kolom;
$pan_str_K = $titel;
$klotenStr = (string)$kloten;
$panelEdit = '[*#vak';
$panelEdit .= $klotenStr;
$panelEdit .= '*]';
switch ($panelKolom)
{
case 1:
$pk = 'left';
break;
case 2:
$pk = 'middle';
break;
case 3:
$pk = 'right';
break;
default:
echo "Het is alleen mogelijk om vakken in de 1e, 2e of 3e kolom te zetten";
}
// Set placeholders:
$modx->setPlaceholder('kop', $pan_str_K);
$modx->setPlaceholder('pStyle', $pk);
$modx->setPlaceholder('edit', $panelEdit);
// set chunk name in this example it is named addressBook
$myChunk = "tplPanel";
// parse the chunk and replace the placeholder values
$values = array('kop' => $pan_str_K, 'pStyle' => $pk, 'edit' => $panelEdit);
// run the parseChunk function
$output = $modx->parseChunk($myChunk, $values, '[+', '+]');
return $output;
?>