It's similar to {bulletmenu} but doesn't show the whole site structure, it only descends down the sections you're in. It doesn't display seperators.
Section headers and links have classes applied to the li.
Code: Select all
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
function smarty_cms_function_bulletmenu2($params, &$smarty) {
global $db;
global $gCms;
# getting menu parameters
$showadmin = isset($params["showadmin"]) ? $params["showadmin"] : 1 ;
# getting content hierarchy parameters
$newparams["show"] = "menu";
$thispage = $gCms->variables['page'];
# track - identify all ancestors of current page
$parent = $thispage;
$parents = array();
array_unshift($parents, $parent);
while ($parent != 0) {
$query = "SELECT page_id, parent_id FROM ".cms_db_prefix()."pages WHERE page_id = '$parent'";
$result = $db->Execute($query);
if ($result && $result->RowCount() > 0) {
$line = $result->FetchRow();
$parent = $line["parent_id"];
}
array_unshift($parents, $parent);
}
# getting content - returns array of all items
$content = db_get_menu_items($newparams);
# defining variables
$menu = "";
$level = array(0);
$changelevel=0;
$menu .= "\n<ul>\n";
# parse content, add to $menu
foreach ($content as $menuitem) {
# do we display this item?
if (in_array($menuitem->parent_id, $parents) && $menuitem->page_type!='seperator') {
# have we changed into another level?
if ($menuitem->parent_id!=end($level)) {
if ($menuitem->parent_id==prev($level)) {
array_pop($level);
$menu .= "</ul>\n</li>\n";
} else {
array_push($level, $menuitem->parent_id);
}
} else $changelevel=0;
if ($menuitem->page_type=='sectionheader') $class=" class=\"sectionheader\"";
elseif ($menuitem->page_type='link') $class=" class=\"link\"";
else $class="";
$menu .= "<li$class>";
if ($menuitem->page_id!=$thispage)
$menu .= "<a href=\"$menuitem->url\">$menuitem->menu_text</a>";
else
$menu .= "<strong>$menuitem->menu_text</strong>";
# any children?
if ($menuitem->childs!="" && in_array($menuitem->page_id, $parents)) {
$menu .= "\n<ul>\n";
} else {
$menu .= "</li>\n";
}
}
}
# descend to ground safely - close off all the tags
while (array_pop($level)) $menu .= "\n</ul>\n</li>\n";
#close off the menu
$menu .= "</ul>\n";
# add admin link if necessary
if ($showadmin == 1) {
$menu .= "<hr />\n<ul><li><a href='admin/'>Admin</a></li></ul>\n";
}
return $menu;
}
function smarty_cms_help_function_bulletmenu2() {
?>
<h3>What does this do?</h3>
<p>Prints a hierachical bullet menu .</p>
<h3>How do I use it?</h3>
<p>Just insert the tag into your template/page like: <code>{bulletmenu2}</code></p>
<h3>What parameters does it take?</h3>
<p>
<ul>
<li><em>(optional)</em> <tt>showadmin</tt> - 1/0, whether you want to show or not the admin link.</li>
</ul>
</p>
<?php
}
function smarty_cms_about_function_bulletmenu2() {
?>
<p>Author: Marcus Deglos <<a href="mailto:md@zioncore.com">md@zioncore.com</a>></p>
<p>Version: 1.0</p>
<p>
Change History:<br/>
None
</p>
<?php
}
# vim:ts=4 sw=4 noet
?>
Marcus.