\n";
foreach ($allcontent as $onecontent)
{
#Handy little trick to figure out how deep in the tree we are
#Remember, content comes to use in order of how it should be displayed in the tree already
$depth = count(split('\.', $onecontent->Hierarchy()));
#If hierarchy starts with the start_element (if it's set), then continue on
if (isset($params['start_element']))
{
if (!(strpos($onecontent->Hierarchy(), $params['start_element']) !== FALSE && strpos($onecontent->Hierarchy(), $params['start_element']) == 0))
{
continue;
}
}
#Now check to make sure we're not too many levels deep if number_of_levels is set
if (isset($params['number_of_levels']))
{
$number_of_levels = $params['number_of_levels'] - 1;
$base_level = 1;
#Is start_element set? If so, reset the base_level to it's level
if (isset($params['start_element']))
{
$base_level = count(split('\.', $params['start_element']));
}
#If this element's level is more than base_level + number_of_levels, then scratch it
if ($base_level + $number_of_levels Active() || !$onecontent->ShowInMenu())
{
continue;
}
if ($onecontent->Type() == 'sectionheader')
{
if ($in_hr == 1)
{
$menu .= "\n\n";
$in_hr = 0;
}
$menu .= "".$onecontent->MenuText()."\n";
if ($count > 0 && $in_hr == 0)
{
$menu .= "";
$in_hr = 1;
}
}
else
{
if ($depth 0)
{
$menu .= "\n\n";
}
}
if ($depth > $last_level) {
for ($i = $depth; $i > $last_level; $i--) $menu .= "\n";
}
if ($depth == $last_level) {
$menu .= "\n";
}
if ($onecontent->Type() == 'separator')
{
$menu .= "";
}
else
{
$menu .= "GetURL().""";
if (isset($gCms->variables['page_id']) && $onecontent->Id() == $gCms->variables['page_id'])
{
$menu .= " class="currentpage"";
}
$menu .= ">".$onecontent->MenuText()."";
}
$in_hr = 1;
$last_level = $depth;
}
$count++;
}
for ($i = 0; $i ";
if ($showadmin == 1)
{
$menu .= "\nAdmin\n";
}
$menu .= "\n";
}
return $menu;
}
function smarty_cms_help_function_simplemenu() {
?>
What does this do?
Prints a bullet menu.
How do I use it?
Just insert the tag into your template/page like: {simplemenu}
What parameters does it take?
(optional) showadmin - 1/0, whether you want to show or not the admin link.
(optional) start_element - the hierarchy of your element (ie : 1.2 or 3.5.1 for example). This parameter sets the root of the menu.
(optional) number_of_levels - an integer, the number of levels you want to show in your menu.
Author: Julien Lancien<
calexico@cmsmadesimple.org>
Version: 1.0
Change History:
None