// -------------------- // Snippet: ListMenuX // -------------------- // Version: 1.2 // Date: 2005.05.31 // [email protected] // // Based on the SimpleListMenu snippet. // // Note: This snippet will only show documents and // folders at the current level and below. // // Credit for the base code goes to [email protected] // based on the SimpleListMenu snippet. // // Usage: // [[ListMenuX?id=0&depth=2&divId=my-menu&activeLinkClass=currentMenuItem]] // $id = !isset($id)?$modx->documentIdentifier:$id; $depth = !isset($depth)?0:$depth; $nodiv = !isset($nodiv)?false:$nodiv; $sDivId = empty($divId)?"":" id='$divId'"; $sDivClass = empty($divClass)?"":" class='$divClass'"; $sUlClass = empty($ulClass)?"":" class='$ulClass'"; $sLiClass = empty($liClass)?"":" class='$liClass'"; $sActiveLinkClass = empty($activeLinkClass)?"":" class='$activeLinkClass'"; $children = $modx->getActiveChildren($id); $menu = ""; $childrenCount = count($children); if($children==false) { return $menu; } if ($nodiv==false) $menu .= "<div$sDivId$sDivClass>\n"; $menu .= "<ul$sUlClass>\n"; foreach ($children as $child) { $level = ($depth < 1)?1:$depth; // If child is current document, add activeLink class if ($child['id']==$modx->documentIdentifier) { $menu .= "<li$sLiClass><a$sActiveLinkClass href='[~".$child['id']."~]' title='".$child['description']."'>".$child['pagetitle']."</a>"; } else { $menu .= "<li$sLiClass><a href='[~".$child['id']."~]' title='".$child['description']."'>".$child['pagetitle']."</a>"; } if ($depth > 1) { $subDepth = $depth - 1; $suffix = "-nested"; if (($snippetOut = $modx->runSnippet('ListMenuX', array('id'=>$child['id'], 'nodiv'=>true, 'divId'=>!empty($divId)?$divId.$suffix:'', 'divClass'=>!empty($divClass)?$divClass.$suffix:'', 'ulClass'=>!empty($ulClass)?$ulClass.$suffix:'', 'liClass'=>!empty($liClass)?$liClass.$suffix:'', 'activeLinkClass'=>!empty($activeLinkClass)?$activeLinkClass:'', 'depth'=>$subDepth ))) != false) { $menu .= $snippetOut; } } $menu .= "</li>\n"; } $menu .= "</ul>\n"; if ($nodiv==false) $menu .= "</div>\n"; return $menu;
will this menu work properly with the current tp3 and the sibdir aliases option. The curent list menu really gets confused on this.
for instans it will go like this
http://liquidthemes.com/home.web
http://liquidthemes.com/theme-testing.web
http://liquidthemes.com/theme-testing/wordpress-themes.web
http://liquidthemes.com/theme-testing/theme-testing/wordpress-themes/rin.web
at any rate you get the idea I end up with extra subdirs which or course does not work correctly.
<base href="http://localhost/some/odd/path/mysite/">
On a side not I’m also finding out just how horrible the orignial is one the database. I’m getting 1 sql call for evey link in the menu. it wonders me why all the links aren’t fetched with a single sql call. That way you could just pull an array of links and spit out the relivent parts of the array. If done properly I suppose depending on how the db is done it would be possible to use the db and make it select on the content you want and use limit to limit the results. It’s amazing to me that most poeple are using php to do the work that the db is supposed to be doing.
As for the sibling problem you are having, I’m not sure I understand. With my <base href=""> solution, it generates the URL’s perfectly for me. Can you explain more about this issue?