Pleasure
In a similar vein (well same part of project anyway),
I think I need to write a snippet that can target a section by id and..
(1) Can then output the menutitle and id for Tier 2 documents (eg: operating systems==2||email solutions==4||middleware solutions==8)
(2) Can output menutitle and id for Tier 3 documents (eg: enterprise linux==50||community linux==51||non linux os==52)
Tier 1: Software index
Tier 2: Software category
Tier 3: Software type
The snippet would be run inside a template variable (i.e. @EVAL return $modx->runSnippet(’MakeOptions’); ) and output the menu titles as checkbox options to tick in documents that have the TV assigned.
Would also need ability to exclude documents by ID (i.e. exclude document id 50 and all it’s children).
There is a snippet out there that is supposed to do some of this (
ddTree) though alas it’s not working (with Evo 1.0.3).
Any pointers gratefully received as always.
ddTree:
<?php
/*
# Name: ddTree (DropDown Tree)
# Version: 1.0.2
# Bug fix by enidan: make depth parameter really optional, and also
# make doc parameter become optional (defaults to 0)
# Author: Urique Dertlian ([email protected])
# Date: Feb 28, 2008
# Using: Create TV of kind "DropDown List Menu", feel elements field with string:
@EVAL return $modx->runSnippet("ddTree",array('doc'=>0,'depth'=>0));
Here 'doc' is identifier of parent document, children of which will be displayed in DropDown menu.
Optional parameter 'depth' is used to limit depth of tree, for example, use 0 (zero) - if you want to display only first level of children.
If depth parametr is not set, ddTree builds up to 100 levels.
*/
$doc = isset($doc) ? $doc : 0;
$depth = isset($depth) ? $depth: 100;
if(!function_exists("getItems"))
{
function getItems($p=0, $d=100, $l=0)
{
global $modx,$modx_charset;
($modx_charset=='UTF-8') ? $nbsp=chr(0xC2).chr(0xA0) : $nbsp=chr(0xA0);
$c=$modx->getDocumentChildren($p);
foreach($c as $k)
{
$out.=str_repeat($nbsp,$l*5).$k['pagetitle']."==".$k['id']."||";
if($l<$d) $out.=getItems($k['id'],$d,$l+1);
}
return $out;
}
}
return getItems($doc,$depth);
?>