www.ucnopodjetje-irrs.org
Posted: Thu 4. Nov 2004, 20:56
My first site with phpwcms: http://www.ucnopodjetje-irrs.org/
I have been looking for decent CMS for a long time and phpwcms seems excellent!
Anyway, I did a little hack - a new replacement tag {NAV_LIST_COLUMN:integer} that acts like {NAV_TABLE_COLUMN:integer} but builds list block (something like <ul><li></li>....</ul>) that you can style with css. Using it in the left column.
Most of the code is based on NAV_TABLE_COLUMN of course...
From content.func.inc.php
From front.func.inc.php
I know, I should put the code in phpwcms_template/inc_script/frontend_render/ but found that a lit too late
Tell me what you think (it's in slovenian so don't expect to understand anything
)
I have been looking for decent CMS for a long time and phpwcms seems excellent!
Anyway, I did a little hack - a new replacement tag {NAV_LIST_COLUMN:integer} that acts like {NAV_TABLE_COLUMN:integer} but builds list block (something like <ul><li></li>....</ul>) that you can style with css. Using it in the left column.
Most of the code is based on NAV_TABLE_COLUMN of course...
From content.func.inc.php
Code: Select all
// Left list based navigation
if( ! ( strpos($content["all"],'{NAV_LIST_COLUMN')===false ) ) {
$content["all"] = str_replace('{NAV_LIST_COLUMN}', '{NAV_LIST_COLUMN:0}', $content["all"]);
$replace = 'nav_list_struct($content["struct"],intval($content["cat_id"]),"$1");';
$content["all"] = preg_replace('/\{NAV_LIST_COLUMN:(\d+)\}/e', $replace, $content["all"]);
}
Code: Select all
function nav_list_struct ($struct, $act_cat_id, $level) {
// start with home directory for the listing = top nav structure
// 1. Build the recursive tree for given actual article category ID
// return the tree starting with given start_id (like breadcrumb)
// if the $start_id = 0 then this stops because 0 = top level
$level = intval($level);
// build temp_tree
$start_id = $act_cat_id;
while ($start_id) {
$data[$start_id] = 1;
$start_id = $struct[$start_id]["acat_struct"];
}
$temp_tree = (sizeof($data)) ? array_reverse($data, 1) : false;
$temp_menu = build_list_levels ($struct, $level, $temp_tree, $act_cat_id, 0);
return $temp_menu;
}
function build_list_levels ($struct, $level, $temp_tree, $act_cat_id, $depth) {
// this returns the level structure based on given arrays
// it is special for browsing from root levels
$temp_menu = "<ul class=\"nav-ul-$depth\">";
$depth++;
foreach($struct as $key => $value) {
if($_SESSION["frontend_user_in"] && $struct[$key]["acat_regonly"]) $struct[$key]["acat_regonly"] = 0;
if($struct[$key]["acat_struct"] == $level && $key && !$struct[$key]["acat_hidden"] && !$struct[$key]["acat_regonly"]) {
// link ce obstaja redirect
if(!$struct[$key]["acat_redirect"]) {
$link = 'index.php?';
if($struct[$key]["acat_alias"]) {
$link .= html_specialchars($struct[$key]["acat_alias"]);
} else {
$link .= 'id='.$key.',0,0,1,0,0';
}
$redirect['target'] = '';
} else {
$redirect = get_redirect_link($struct[$key]["acat_redirect"], ' ', '');
$link = $redirect['link'];
}
// rekurzivno ...
if($temp_tree[$key]) {
if($act_cat_id == $key) {
$temp_menu .= "<li class=\"nav-li-active\">";
$temp_menu .= '<a href="'.$link.'"'.$redirect['target'].'>'.html_specialchars($struct[$key]["acat_name"]).'</a>';
} else {
$temp_menu .= "<li>";
$temp_menu .= '<a href="'.$link.'"'.$redirect['target'].'>'.html_specialchars($struct[$key]["acat_name"]).'</a>';
}
$temp_menu .= build_list_levels ($struct, $key, $temp_tree, $act_cat_id, $depth);
$temp_menu .= "</li>\n";
} else {
$temp_menu .= "<li>";
$temp_menu .= '<a href="'.$link.'"'.$redirect['target'].'>'.html_specialchars($struct[$key]["acat_name"]).'</a>';
$temp_menu .= "</li>";
}
}
}
$temp_menu .= "</ul>";
// KONEC
return $temp_menu;
}
![Smile :)](./images/smilies/icon_smile.gif)
Tell me what you think (it's in slovenian so don't expect to understand anything
![Smile :)](./images/smilies/icon_smile.gif)