NAVIGATION
This shows you the differences between two versions of the page.
deutsch:ersetzer_rts:frontend_render:nav_list_ul-article-count:v1-51 [2011/04/25 08:50] Knut Heermann (flip-flop) |
deutsch:ersetzer_rts:frontend_render:nav_list_ul-article-count:v1-51 [2018/06/03 18:09] (current) |
||
---|---|---|---|
Line 359: | Line 359: | ||
} | } | ||
+ | return $ul; | ||
+ | } | ||
+ | |||
+ | if(!empty($content["all"]) && !(strpos($content["all"],'{NLU_FF_AC_QD:')===false)) { | ||
+ | $content["all"] = preg_replace('/\{NLU_FF_AC_QD:(.*?)\}/e', 'buildCascMenuCountArticles("$1",0,string,'.$acw_count.','.$acw_title.');', $content["all"]); | ||
+ | } | ||
+ | |||
+ | |||
+ | ?> | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | ==== Quelltext V1.5.1a ==== | ||
+ | |||
+ | **UPDATE 02.05.2011:** | ||
+ | * title-Text im Parent-Link korrigiert | ||
+ | * BBcode in Linktext parsen und im title-Text entfernen | ||
+ | |||
+ | \\ | ||
+ | **Dateiname:** rt_NLU_FF_AC_QD_1.51a.php | ||
+ | |||
+ | |||
+ | <code |h rt_NLU_FF_AC_QD_1.51a |h > | ||
+ | <?php | ||
+ | /****************************************************************** | ||
+ | * NLU_FF_AC_QD for phpwcms --> r403 v1.4.7+ | ||
+ | * Date: Nov. 28, 2010 | ||
+ | * | ||
+ | * UPDATE: KH 24/04/2011 V1.5.1 | ||
+ | * ADDED: Switch [0|1] article count off|on | ||
+ | * Switch [0|1] category title off|on (from field "page title:" instead of "category title:") | ||
+ | * UPDATE: KH 02/05/2011 V1.5.1a | ||
+ | * Correction: Title text from field "page title" in parent link | ||
+ | * ADDED: Typical html formattings (bbcode) in linkname. In title containing bbcode is removed. | ||
+ | * | ||
+ | * | ||
+ | * SUMMARY: | ||
+ | * Works like NAV_LIST_UL but displays the number of articles | ||
+ | * --> of each site level. Example ==> Products (17) | ||
+ | * | ||
+ | * AUTHOR [virt.]: Jensensen | ||
+ | * INSPIRED by Knut Heermann aka flip-flop | ||
+ | * FUNCTION by Oliver Georgi | ||
+ | * README: Forum | ||
+ | * http://forum.phpwcms.org/viewtopic.php?p=100208#p100208 | ||
+ | * http://forum.phpwcms.org/viewtopic.php?f=8&t=17891 | ||
+ | * | ||
+ | * README: Wiki | ||
+ | * http://www.phpwcms-howto.de/wiki/doku.php/english/phpwcms_replacer_rts/frontend_render/nav_list_ul-article-count | ||
+ | * http://www.phpwcms-howto.de/wiki/doku.php/deutsch/ersetzer_rts/frontend_render/nav_list_ul-article-count | ||
+ | * | ||
+ | * TAG: {NLU_FF_AC_QD:F,0....} | ||
+ | * Use it in your templates, CPs or elsewhere. | ||
+ | * | ||
+ | * VERSION: 1.5.1a | ||
+ | * CONDITION: FREE || leckmichandefurtoderscheissdiewandan; | ||
+ | * LICENCE: |∀| ∀ | ||
+ | * | ||
+ | * LOCATION: /template/inc_script/frontend_render/rt_NLU_FF_AC_QD_1.51a.php | ||
+ | * REQUIREMENT: $phpwcms['allow_ext_render'] = 1; //SEE: conf.inc.php | ||
+ | * | ||
+ | * NAV_LIST_UL basics: http://forum.phpwcms.org/viewtopic.php?t=12165 | ||
+ | * | ||
+ | * ****************************************************************/ | ||
+ | // 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>"; | ||
+ | $acw_count = 1; // [0|1] article count off|on | ||
+ | |||
+ | // Category title from field "page title:" instead of "category title:" | ||
+ | $acw_title = 1; // [0|1] category title off|on | ||
+ | |||
+ | /****************************************************************** | ||
+ | * ### !!!!!!!!!!! ### NO NEED TO EDIT BELOW ### !!!!!!!!!!!!!!! ### | ||
+ | ******************************************************************/ | ||
+ | |||
+ | |||
+ | // -- <E01> ------------------------------------------------------------------- | ||
+ | function my_render_bbcode_basics($text, $mode='basic') { | ||
+ | // EDIT: 11/05/02 KH. (flip-flop) including simple Tags in category headline from the file | ||
+ | // /include/inc_front/front.func.inc.php and the function html_parser($string) | ||
+ | // you can copy&paste what you want. | ||
+ | |||
+ | // typical html formattings | ||
+ | |||
+ | $search[18] = '/\[i\](.*?)\[\/i\]/is'; | ||
+ | $search[19] = '/\[u\](.*?)\[\/u\]/is'; | ||
+ | $search[20] = '/\[s\](.*?)\[\/s\]/is'; | ||
+ | $search[21] = '/\[b\](.*?)\[\/b\]/is'; | ||
+ | $search[22] = '/\[br\]/is'; | ||
+ | |||
+ | IF ($mode === 'basic') { | ||
+ | $replace[18] = '<i>$1</i>'; | ||
+ | $replace[19] = '<u>$1</u>'; | ||
+ | $replace[20] = '<strike>$1</strike>'; | ||
+ | $replace[21] = '<strong>$1</strong>'; | ||
+ | $replace[21] = '<strong>$1</strong>'; | ||
+ | $replace[22] = '<br>'; | ||
+ | } | ||
+ | ELSE | ||
+ | $replace = array(''); // e.g .mode = 'clean'; | ||
+ | |||
+ | |||
+ | return preg_replace($search, $replace, $text); | ||
+ | |||
+ | } | ||
+ | // -- <E01> ------------------------------------------------------------------- | ||
+ | |||
+ | |||
+ | |||
+ | // original funtion buildCascadingMenu in /include/inc_front/front.func.inc.php | ||
+ | function buildCascMenuCountArticles($parameter='', $counter=0, $param='string',$acw_count=1, $acw_title=1) { | ||
+ | |||
+ | // @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_level)" | ||
+ | |||
+ | |||
+ | 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('|', trim($parameter[7]), 2); | ||
+ | if(empty($wrap_link_text[1])) { | ||
+ | $wrap_link_text[1] = ''; | ||
+ | } | ||
+ | $amenu_level = 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_level, | ||
+ | 12 => array('articlemenu' => $articlemenu, 'level_id' => $start_id) | ||
+ | ); | ||
+ | |||
+ | if($articlemenu) { | ||
+ | $parameter[12]['class_active'] = $active_class; | ||
+ | $parameter[12]['wrap_title_prefix'] = $wrap_link_text[0]; | ||
+ | $parameter[12]['wrap_title_suffix'] = $wrap_link_text[1]; | ||
+ | $parameter[12]['item_prefix'] = "\t"; | ||
+ | $parameter[12]['item_suffix'] = ''; | ||
+ | $parameter[12]['sort'] = 'level'; | ||
+ | $parameter[12]['item_tag'] = 'li'; | ||
+ | $parameter[12]['wrap_tag'] = ''; | ||
+ | $parameter[12]['attribute_wrap_tag'] = ''; | ||
+ | $parameter[12]['class_item_tag'] = 'asub_no'; | ||
+ | $parameter[12]['class_first_item_tag'] = 'asub_first'; | ||
+ | $parameter[12]['class_last_item_tag'] = 'asub_last'; | ||
+ | $parameter[12]['return_format'] = 'array'; | ||
+ | } | ||
+ | |||
+ | } 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_level = $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) { | ||
+ | |||
+ | |||
+ | if ($acw_count === 1) { | ||
+ | // -------------------------------------- WORKING ----------------- | ||
+ | // thank you OG | ||
+ | // count number of articles in each category level | ||
+ | $sql = "SELECT COUNT(*) "; | ||
+ | $sql .= "FROM ".DB_PREPEND."phpwcms_article "; | ||
+ | $sql .= 'WHERE article_cid=' . $key . ' AND article_deleted=0 AND article_public=1 '; | ||
+ | $sql .= 'AND article_aktiv=1 AND article_begin<NOW() AND '; | ||
+ | $sql .= 'IF(article_archive_status=1, 1, article_end>NOW())'; | ||
+ | // ---------------------------------------------------------------- | ||
+ | |||
+ | // thank you flip-flop | ||
+ | $how_many_articles = _dbCount($sql); | ||
+ | } | ||
+ | |||
+ | if( _getStructureLevelDisplayStatus($key, $start_id) ) { | ||
+ | |||
+ | $li_ul = ''; | ||
+ | $li_ie = ''; | ||
+ | $li_a_title = html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']); | ||
+ | |||
+ | // +KH 24.04.2011: title tag from field "page title:" | ||
+ | $li_a_inner_title = (empty($GLOBALS['content']['struct'][$key]['acat_pagetitle']) OR $acw_title !== 1) ? html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']) : html_specialchars($GLOBALS['content']['struct'][$key]['acat_pagetitle']); | ||
+ | $li_a_inner_title = my_render_bbcode_basics($li_a_inner_title, 'clean'); // clean up bbcode | ||
+ | |||
+ | $li_a = get_level_ahref($key, ' title="'.$li_a_inner_title.'"'); | ||
+ | $li_a .= $wrap_link_text[0] . $li_a_title . $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 = buildCascMenuCountArticles($parameter, $counter+1, 'param_is_array', $acw_count,$acw_title); // jensensen | ||
+ | } | ||
+ | |||
+ | $li .= $TAB.' <li'; | ||
+ | |||
+ | if($level_id_name) { | ||
+ | $li .= ' id="li_'.$level_id_name.'_'.$key.'"'; | ||
+ | } | ||
+ | $li_class = ($li_ul) ? 'sub_ul' : (getHasSubStructureStatus($key) ? 'sub_no sub_ul_true' : 'sub_no'); | ||
+ | if($path_class != '' && isset($GLOBALS['LEVEL_KEY'][$key])) { | ||
+ | $li_class = trim($li_class.' '.$path_class); | ||
+ | } | ||
+ | if($active_class != '' && $key == $GLOBALS['aktion'][0]) { | ||
+ | $li_class = trim($li_class.' '.$active_class); | ||
+ | } | ||
+ | if($x==0) { | ||
+ | $li_class .= ' sub_first'; | ||
+ | } | ||
+ | |||
+ | $li .= ' class="' . trim($li_class . ' ' . $GLOBALS['content']['struct'][$key]['acat_class']) .'"'; | ||
+ | |||
+ | // $li .= '>' . $li_a . '</a>'; | ||
+ | // $li .= '>' . $li_a . $GLOBALS['acw_before'] . $how_many_articles . $GLOBALS['acw_after'] . '</a>'; // jensensen | ||
+ | $li .= '>' . $li_a . (($acw_count===1) ? $GLOBALS['acw_before'] . $how_many_articles . $GLOBALS['acw_after'] :'') . '</a>'; // jensensen | ||
+ | |||
+ | $li .= $li_ul.'</li>'.LF; // remove $li_ul from this line of code if $ie_patch is used | ||
+ | |||
+ | $x++; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // show article menu | ||
+ | if($parameter[12]['articlemenu'] && $amenu_level <= $counter) { | ||
+ | |||
+ | $parameter[12]['level_id'] = $start_id; | ||
+ | $parameter[12]['item_prefix'] = $TAB; | ||
+ | |||
+ | $ali = getArticleMenu( $parameter[12] ); | ||
+ | |||
+ | if(count($ali) > 1) { | ||
+ | |||
+ | $li .= implode(LF, $ali) . LF; | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | // 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($active_class != '' && $start_id == $GLOBALS['aktion'][0]) { | ||
+ | $li_class = trim($li_class.' '.$active_class); | ||
+ | } | ||
+ | $ul .= ' class="'.trim($li_class.' '.$GLOBALS['content']['struct'][$start_id]['acat_class']).'">'; | ||
+ | |||
+ | $link_text = html_specialchars($GLOBALS['content']['struct'][$start_id]['acat_name']); | ||
+ | |||
+ | // +KH 24.04.2011: title tag from field "page title:" | ||
+ | $li_a_inner_title = (empty($GLOBALS['content']['struct'][$start_id]['acat_pagetitle']) OR $acw_title !== 1) ? html_specialchars($GLOBALS['content']['struct'][$start_id]['acat_name']) : html_specialchars($GLOBALS['content']['struct'][$start_id]['acat_pagetitle']); | ||
+ | $li_a_inner_title = my_render_bbcode_basics($li_a_inner_title, 'clean'); // clean up bbcode | ||
+ | |||
+ | $ul .= get_level_ahref($start_id, ' title="'.$li_a_inner_title.'"'); | ||
+ | $ul .= $wrap_link_text[0] . $link_text . $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>'; | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | //+KH 02.05.2011: Replace typical html formattings (bbcode) | ||
+ | $ul = my_render_bbcode_basics($ul, 'basic'); | ||
+ | |||
return $ul; | return $ul; | ||
} | } |