//ID of page for category links
$pageid = 1;
//Name of Template Variable used for categories
$tmplvarname = "TmplCategories";
//CSS Class Name
$classname = "childrens";
//CSS ID Name
$idname = "childrens";
$dbase = $modx->dbConfig['dbase'];
$sql = "SELECT * FROM ".$dbase.".".$table_prefix."modx_site_tmplvars WHERE name='".$tmplvarname."'";
$rs = $etomite->dbQuery($sql);
$row_rs = mysql_fetch_assoc($rs);
$elementsarr = explode("||",$row_rs["elements"]);
$output = '<div'.($idname<>""?' id="'.$idname.'"':'').($classname<>""?' class="'.$classname.'"':'').'><ul>';
foreach($elementsarr as $v){
list($item,$itemvalue) = explode("==",$v);
$output .= "<li><a href='[~".$pageid."~]?cat=".$itemvalue."'>".$item."</a></li>\n";
}
return $output."</ul></div>\n";
//Set to the default folder for category pages
$pid = 3;
// list order by specified field
if(!isset($order) || $order == ''){
$order='menuindex';
}
// return false if no category is set
if(!isset($_GET['cat']) || $_GET['cat'] == ''){
return false;
}else{
$cat = $_GET['cat'];
}
// get childrens, and show some info when no childrens founds
$children = $etomite->getDocumentChildrenTVars($pid,array("PortfolioCats","id","pagetitle"),1,$order);
if($children == false){
return '<blockquote>No categories to show</blockquote>';
}
// close list in div (optional, you can change it, whatever)
$menu = '<div id="childrens"><ul>';
$childrenCount = count($children);
// lists all childrens as links
for($x=0; $x<$childrenCount; $x++) {
$childarray = explode("||",$children[$x][0]["value"]);
for($i=0; $i <= count($childarray); $i++){
if($childarray[$i] == $cat){
$menu .= "<li><a href='[~".$children[$x][1]["value"]."~]'$active>".$children[$x][2]["value"]."</a></li>";
}
}
}
return $menu."</ul></div>\n";

Simply set the $pid to the ID of the folder that will store your category pages.? This output another list menu showing the pages in the given category as selected by a $cat variable from your category menu.? Of course, you can choose to have this menu on the same page as your category menu.? If the $cat variable isn’t present in the URL, no output will be shown.? You can name this snippet to whatever you want as well...just give it a name that makes sense to you.

&pid=Parent id;string;1


Thanks Jeff... care to share a link?



I haven’t installed this yet but I was wondering if the categories can be pulled up dynamically?
This discussion is closed to further replies. Keep calm and carry on.