NAVIGATION
This is an old revision of the document!
RT Wenn die Ausgabe der Artikelanzahl jeder Strukturebene hinter dem jeweiligen Linknamen gewünscht ist, kann dieser Tag verwendet werden.
Dies ist eine kurze und knappe Lösung!
Dies ist die originale NAV_LIST_UL von OG (CSS by flip-flop)erweitert mit –> Ausgabe Anzahl der Artikel der jeweiligen Strukturebene.
Das Skript arbeitet exakt wie NAV_LIST_UL. Es werden also die selben Parameter verwendet.
Beispielmenü:
Firma (4)
Produkte (37)
Personal (12)
Dies bedarf eines speziellen Ersetzers replacement tag
NLU_FF_AC_QD
Das Ausgabeformat kann an die eigenen Wünsche angepasst werden:
(12) or [12] or -12 …..
Dann editiere
// Article Count Wrapper $acw_before = " <span>("; $acw_after = ")</span>";
Verwendung:
{NLU_FF_AC_QD:F,5,,count_articles,active}
Elternelementausgabe:
{NLU_FF_AC_QD:FP,4,2,act_path,active}
Inline PHP:
[PHP] if(isset($GLOBALS['LEVEL_ID'][1])) { $level_id = $GLOBALS['LEVEL_ID'][1]; echo '<div class="my_navi_with_the_number_of_articles_in_the_site_structure_level">'; echo '{NLU_FF_AC_QD:,'.$level_id.',1,act_path,active}'; echo '</div>'; } [/PHP]
FÜr alle die es interessiert, wie sich der Name zusammensetzt:
- NLU = NAV_LIST_UL
- FF = flip-flop
- AC = article count
- QD = quick and dirty
<note> Limitierung: Es gibt eine Einschränkung. Das Skript zählt nur die Artikel die in der eigenen einen Strukturebene liegen. Es gibt keine Summierung über die Strukturebenen hinweg. Artikel in Unterkategorien werden also in der darüber liegenden Ebene nicht mitgezählt)! </note>
Beispiel: Produkte (1 Artikel)
Ausgabe:
Produkt (1)
Produkt_A (17)
Produkt_B (3)
Es wird also nicht ausgegeben:
rt_NLU_FF_AC_QD_1.1 V1.0 2008/09/08
Docu: –
Forum: article counter near category name (menu) in visitor page
NLU_FF_AC_QD (update v.1.1)
Autor: Jensensen
CMS Version: >= 1.3
Version: V1.0
Update: V1.1 2009/02/23
Tag: {NLU_FF_AC_QD:F,0….}
Dateiname: rt_NLU_FF_AC_QD_1.1.php
Verzeichnis: template/inc_script/frontend_render/
Bedingung: → /config/phpwcms/conf.inc.php
<?php /****************************************************************** * NLU_FF_AC_QD for phpwcms --> v1.3+ * * Date: Feb. 23, 2009 by Jensensen * * Works like NAV_LIST_UL but displays the number of articles * --> of each site level, example ==> Products (17) * * AUTHOR: Jensensen * inspired by flip-flop || function by OG. * * http://forum.phpwcms.org/viewtopic.php?p=100208#p100208 * http://forum.phpwcms.org/viewtopic.php?f=8&t=17891 * * TAG: {NLU_FF_AC_QD:F,0....} * Copy to your templates / CPs * * Version: 1.1 * Condition: free * Location: /template/inc_script/frontend_render/rt_NLU_FF_AC_QD_1.1.php * Requirement: $phpwcms['allow_ext_render'] = 1; in conf.inc.php * * ****************************************************************/ // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- /***************************************************************** * ### PARAMETER SET UP ### !!!!!!!!!!!!!!!!!!!!!!!!! ### *****************************************************************/ // Article Count Wrapper $acw_before = " <span>("; $acw_after = ")</span>"; /***************************************************************** * ### !!!!!!!!!!! ### NO NEED TO EDIT BELOW ### !!!!!!!!!!!!!! ### *****************************************************************/ function buildMenuCountArticles($parameter='', $counter=0, $param='string') { // @string $parameter = "menu_type, start_id, max_level_depth, class_path, class_active, // ul_id_name, wrap_ul_div(0 = off, 1 = <div>, 2 = <div id="">, 3 = <div class="navLevel-0">), // wrap_link_text(<em>|</em>, articlemenu_start_id)" if($param == 'string') { $parameter = explode(',', $parameter); $menu_type = empty($parameter[0]) ? '' : strtoupper(trim($parameter[0])); $unfold = 'all'; $ie_patch = false; // unused at the moment $create_css = false; $parent = false; // do not show parent link $articlemenu = false; // do not show category's article titles as menu entry switch($menu_type) { // show parent level too case 'PA': $articlemenu = true; case 'P': $parent = true; break; // vertical, active path unfolded case 'FPA': $articlemenu = true; case 'FP': $parent = true; case 'F': $unfold = 'active_path'; break; case 'FA': $articlemenu = true; $unfold = 'active_path'; break; // horizontal, all levels unfolded, add special code for horizontal flyout menu case 'HCSSP': $parent = true; case 'HCSS': $create_css = true; break; // horizontal, all levels unfolded, add special code for vertical flyout menu case 'VCSSP': $parent = true; case 'VCSS': $create_css = true; break; } $start_id = empty($parameter[1]) ? 0 : intval($parameter[1]); $max_depth = empty($parameter[2]) ? 0 : intval($parameter[2]); $path_class = empty($parameter[3]) ? '' : trim($parameter[3]); $active_class = empty($parameter[4]) ? '' : trim($parameter[4]); $level_id_name = empty($parameter[5]) ? '' : trim($parameter[5]); $wrap_ul_div = empty($parameter[6]) ? 0 : intval($parameter[6]); if($wrap_ul_div > 3) { $wrap_ul_div = 2; } elseif($wrap_ul_div < 0) { $wrap_ul_div = 0; } $wrap_link_text = empty($parameter[7]) ? array(0 => '', 1 => '') : explode('|', $parameter[7]); if(empty($wrap_link_text[1])) { $wrap_link_text[1] = ''; } $amenu_start_id = empty($parameter[8]) ? 0 : intval($parameter[8]); $parameter = array( 0 => $menu_type, 1 => $start_id, 2 => $max_depth, 3 => $path_class, 4 => $active_class, 5 => $level_id_name, 6 => $wrap_ul_div, 7 => $wrap_link_text, 8 => $unfold, 9 => $ie_patch, 10 => $create_css, 11 => $amenu_start_id ); } else { $menu_type = $parameter[0]; $start_id = $parameter[1]; $max_depth = $parameter[2]; $path_class = $parameter[3]; $active_class = $parameter[4]; $level_id_name = $parameter[5]; $wrap_ul_div = $parameter[6]; $wrap_link_text = $parameter[7]; $unfold = $parameter[8]; $ie_patch = $parameter[9]; $create_css = $parameter[10]; $amenu_start_id = $parameter[11]; $parent = false; // do not show parent link } $li = ''; $ul = ''; $TAB = str_repeat(' ', $counter); $_menu_type = strtolower($menu_type); $max_depth = ($max_depth == 0 || $max_depth-1 > $counter) ? true : false; $x = 0; foreach($GLOBALS['content']['struct'] as $key => $value) { // count number of articles in each category level $sql = "SELECT * "; $sql .= "FROM ".DB_PREPEND."phpwcms_article "; $sql .= "WHERE article_cid=$key "; $sql .= "AND article_public=1 AND article_aktiv=1"; // thank you flip-flop $how_many_articles = _dbCount($sql); //if($GLOBALS['content']['struct'][$key]['acat_struct'] == $start_id && $key && (!$GLOBALS['content']['struct'][$key]['acat_hidden'] || ($GLOBALS['content']['struct'][$key]["acat_hidden"] == 2 && isset($GLOBALS['LEVEL_KEY'][$key])))) { if( _getStructureLevelDisplayStatus($key, $start_id) ) { $li_ul = ''; $li_class = ''; $li_ie = ''; $li_a = get_level_ahref($key); $li_a .= $wrap_link_text[0]; $li_a .= html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']); $li_a .= $wrap_link_text[1]; if($max_depth && ($unfold == 'all' || ($unfold == 'active_path' && isset($GLOBALS['LEVEL_KEY'][$key]))) ) { $parameter[1] = $key; // $li_ul = buildCascadingMenu($parameter, $counter+1, 'param_is_array'); $li_ul = buildMenuCountArticles($parameter, $counter+1, 'param_is_array'); } $li .= $TAB.' <li'; if($level_id_name) { $li .= ' id="li_'.$level_id_name.'_'.$key.'"'; } if($li_ul) { $li_class = 'sub_ul'; } else { $li_class = getHasSubStructureStatus($key) ? 'sub_no sub_ul_true' : 'sub_no'; } if($path_class != '' && isset($GLOBALS['LEVEL_KEY'][$key])) { $li_class .= ' '.$path_class; $li_class = trim($li_class); } if($active_class != '' && $key == $GLOBALS['aktion'][0]) { $li_class = trim($li_class.' '.$active_class); } $li .= ' class="' . $li_class . ( $x==0 ? ' sub_first' : '' ) .'"'; // $li .= '>' . $li_a . '</a>'; $li .= '>' . $li_a . $GLOBALS['acw_before'].$how_many_articles.$GLOBALS['acw_after'] . '</a>'; $li .= $li_ul.'</li>'.LF; // remove $li_ul from this line of code if $ie_patch is used $x++; } } // also check if $parent if($li || ($parent && isset($GLOBALS['content']['struct'][$start_id]))) { switch($wrap_ul_div) { case 1: $ul = LF.$TAB.'<div>'; $close_wrap_ul = '</div>'.LF.$TAB; break; case 2: $ul = LF.$TAB.'<div id="ul_div_'.$start_id.'">'; $close_wrap_ul = '</div>'.LF.$TAB; break; case 3: $ul = LF.$TAB.'<div class="navLevel-'.$counter.'">'; $close_wrap_ul = '</div>'.LF.$TAB; break; default: $ul = ''; $close_wrap_ul = ''; } $ul .= LF.$TAB.'<ul'; if($level_id_name) { $ul .= ' id="'.$level_id_name.'_'.$start_id.'"'; } if(isset($GLOBALS['LEVEL_KEY'][$start_id]) && $path_class) { $ul .= ' class="'.$path_class.'"'; } $ul .= '>'.LF; if($parent && isset($GLOBALS['content']['struct'][$start_id])) { $ul .= LF; $ul .= $TAB.' <li'; if($level_id_name) { $ul .= ' id="li_'.$level_id_name.'_'.$start_id.'"'; } $li_class = 'sub_parent'; if($path_class != '' && isset($GLOBALS['LEVEL_KEY'][$start_id])) { $li_class .= ' '.$path_class; $li_class = trim($li_class); } if($active_class != '' && $start_id == $GLOBALS['aktion'][0]) { $li_class = trim($li_class.' '.$active_class); } $ul .= ' class="'.$li_class.'">'; $ul .= get_level_ahref($start_id); $ul .= $wrap_link_text[0]; $ul .= html_specialchars($GLOBALS['content']['struct'][$start_id]['acat_name']); $ul .= $wrap_link_text[1]; $ul .= '</a></li>'.LF; } $ul .= $li; $ul .= $TAB . '</ul>' . LF . $TAB . $close_wrap_ul; if($create_css && empty($GLOBALS['block']['custom_htmlhead'][$menu_type][$counter])) { if($counter) { $tmp_css = ' .'.$_menu_type.'_menu ul li:hover '.str_repeat('ul ', $counter) .'ul { display: none; }'.LF; $tmp_css .= ' .'.$_menu_type.'_menu ul '.str_repeat('ul ', $counter) .'li:hover ul { display: block; }'; $GLOBALS['block']['custom_htmlhead'][$menu_type][$counter] = $tmp_css; } else { //if($counter == 0) { $GLOBALS['block']['custom_htmlhead'][$menu_type][-9] = LF.' <style type="text/css">'.LF.SCRIPT_CDATA_START; $GLOBALS['block']['custom_htmlhead'][$menu_type][-8] = ' @import url("'.TEMPLATE_PATH.'inc_css/specific/nav_list_ul_'.$_menu_type.'.css");'; $GLOBALS['block']['custom_htmlhead'][$menu_type][-5] = ' .'.$_menu_type.'_menu ul ul { display: none; }'; $GLOBALS['block']['custom_htmlhead'][$menu_type][-4] = ' .'.$_menu_type.'_menu ul li:hover ul { display: block; }'; ksort($GLOBALS['block']['custom_htmlhead'][$menu_type]); $GLOBALS['block']['custom_htmlhead'][$menu_type][] = SCRIPT_CDATA_END.LF.' </style>'; $GLOBALS['block']['custom_htmlhead'][$menu_type] = implode(LF, $GLOBALS['block']['custom_htmlhead'][$menu_type]); $ul = '<div class="'.$_menu_type.'_menu">'.$ul.'</div>'; } } } return $ul; } if(!empty($content["all"]) && !(strpos($content["all"],'{NLU_FF_AC_QD:')===false)) { $content["all"] = preg_replace('/\{NLU_FF_AC_QD:(.*?)\}/e', 'buildMenuCountArticles("$1");', $content["all"]); } ?>