first of all, you guys do great things here, and a pocket full of glory to the Developer and the fit ones!
I just started working with phpWCMS and at the moment I´m trying to get the possibilities of Navigation Customizing.
I think it would be handy to have a Replacment Tag like
{NAV_LIST_LEVEL:parent_level:class}
so you can specify the output of a menu at every position from every positon in the level structure. I also wanted to have an "_active" id on the List Item which is currently selected.
My solution to that is pretty poor because I just look if $level is the same as given $parent_level.
If it is possible to detect the currently selected level depending on the given parent_level it would be much more flexible ...
Code:
front.func.inc.php
Code: Select all
function css_list_level($struct, $struct_path, $level, $parent_level=0, $class="list_level") {
// returns list <div><ul><li></li></ul></div> of the structure level down from given parent_level
// predefined class for this menu is "list_level"
if(!trim($class)) $class = "list_level";
$parent_level_name = trim($parent_level_name);
$level = intval($level);
$parent_level = intval($parent_level);
$activated = 0; //no active list set
$css_list = "";
//returns the complete level of NON hidden categories
$level_struct = return_struct_level($struct, $parent_level);
if(sizeof($level_struct)) {
foreach($level_struct as $key => $value) {
$link = $link_to."?"; //id=".$key.",0,0,1,0,0";
$link .= ($level_struct[$key]["acat_alias"]) ? html_specialchars($level_struct[$key]["acat_alias"]) : "id=".$key.",0,0,1,0,0";
$css_list .= " <li";
$css_list .= ($level == $key) ? " id=\"".$class."_active\"":" id=\"".$class."_inactive\"";
$css_list .= '><a href="'.$link.'"';
$css_list .= ' target="_top">'.html_specialchars($level_struct[$key]["acat_name"])."</a>";
$css_list .= "</li>\n";
}
}
if($css_list) {
$css_list = "<div id=\"".$class."\">\n <ul id=\"".$class."_ul\">\n". $css_list ." </ul>\n</div>";
}
return $css_list;
}
content.func.inc.php
Code: Select all
// -------------------------------------------------------------
// List based navigation of Single given Level - default listing Level 0
if( ! ( strpos($content["all"],'{NAV_LIST_LEVEL')===false ) ) {
$content["all"] = str_replace('{NAV_LIST_LEVEL}', css_list_level($content["struct"],$content["cat_path"],$content["cat_id"]), $content["all"]);
// creates a list styled nav menu of current level {NAV_LIST_LEVEL:active_level:class_name} | default class name = list_top
$content["all"] = preg_replace('/\{NAV_LIST_LEVEL:(.*?):(.*?)\}/e', 'css_list_level($content["struct"],$content["cat_path"],$content["cat_id"],"$1","$2")', $content["all"]);
}
// -------------------------------------------------------------
So maybe there have been already some sophisticated solutions to this task but I simply didn´t find them, just show them please.
Cheers & Thank you
Uli