OK, I’ve got it working mostly, but it’s not pulling the data correctly. The problem is that I’m trying to create a sub menu for a menu populated by Ditto. I know, I know - use Wayfinder, right? Well, I can’t use Wayfinder in this instance. The client is making links on the Widget, Thingamabobs, and Dingle-hopper pages. Those links need to be listed as Item 1, Item 2, Item 3, Item 4. Well, the problem is that they’re being made by the client with TinyMCE and he wants anchor links to take people straight to the items (e.g., "/widgets.html#item1").
Parent Page (Ditto menu built here)
- Widgets
-- Item 1
-- Item 2
-- Item 3
-- Item 4
- Thingamabobs
-- Item 1
-- Item 2
-- Item 3
-- Item 4
- Dingle-hoppers
-- Item 1
-- Item 2
-- Item 3
-- Item 4
Right now I’m trying to do this with a custom snippet:
<?php
/**
* Convert a text with linebreaks to a html list
* written by Roman
*/
$chunk = isset($chunk) ? $chunk : false;
$tv = isset($tv) ? $tv : false;
$delimiter = isset($delimiter) ? $delimiter : "\n";
$docid = isset($docid) ? $docid : $modx->documentObject['id'];
if($tv){
$tvArray = $modx->getTemplateVarOutput(array($tv), $docid);
if(!$tvArray[$tv])
return;
$text = $tvArray[$tv];
} else if($chunk){
$text = $modx->getChunk($chunk);
if(!$text)
return;
} else {
return;
}
$lines = explode($delimiter, $text);
$out = '<ul>';
foreach($lines as $line){
$out .= '<li>' . trim($line) . '</li>';
}
$out .= '</ul>';
return $out;
?>
This snippet calls on a text area tv where the links are built manually and separated by line breaks.
<a href="/sample.html#sample1">Sample 1</a>
<a href="/sample.html#sample2">Sample 2</a>
<a href="/sample.html#sample3">Sample 3</a>
right now I can’t refer back to the tv on the widget pages properly. Nothing renders. How can I refer to that tv with this set up? In other words - how can I reference a tv from the child to display in the parent? I think that’s all it comes down to.