Hi Guys,
Can't seem to find much on this topic of using a checkbox.
Situation: I have a sidebar that can show a myriad of things, the usual information stuff. I want to allow to use to select which items will be shown on the sidebar. I can do this easily with setting each one to be its own checkbox, however it doesn't look great. So I decided to group them into 1 Checkbox themselves and then display whatever is checked.
Setup:
User End:
TV Setup:
Currently Tried:
It seems when I call the [[*Sidebar]] TV it just lists out what has been checked. Great, I can work with that, however it's not in an array its literally a string with no way of exploding it out.
I created a Snippet to take the TV and the current Page Id to determine what was checked.
$parent = (int)$modx->getOption('parent', $scriptProperties, '');
$tpl = $modx->getOption('tpl', $scriptProperties, 'sidebar_chunk');
$page = $modx->getObject('modResource', $parent);
print_r($page->getTVValue('Sidebar'));
This does the same as just calling the TV so not much use there. After a bit more digging around I was getting close but I still feel I'm missing something
$tv = $modx->getObject('modTemplateVar',array('name'=>'Sidebar'));
$optionValues = $tv->get('elements');
print_r($optionValues);
This prints out: Eurofilms TV||Collation Shrink||Film Optimization Chart||Form Fill and Seal||Packaging Audit||Pre Stretch Insight||Sample Audit Pack||Shrink Film
Now on first look I got an instant coder's high thinking I had finally solved this problem, and then I looked again, it had just listed out everything when only 4 had been ticked. If it had printed out everything I.E. Eurofilms TV==1||Collation Shrink==0 I can work with explodes etc.
I could be making a mountain out of a molehill here and potentially googling all the wrong keywords.
I can see this being a really simple solution but I just can't seem to nail it.
Any help would be appreciated.
Thanks, Ross.