{{indexmenu_n>18}} ====== {XBROWSE:NEXT/PREV/UP:LinkText:X} ====== An extended [[http://www.phpwcms-docu.de/navigation_tags.phtml|(BROWSE :....}]] tag, which can produce optional link texts like the article title/subtitle or category title. In the Product List mode, a loop is adjustable, which branches in PREV from the first to the last and in NEXT from the last to the first article. The familiar settings of the tag [[http://www.phpwcms-docu.de/navigation_tags.phtml|{BROWSE:....}]] can be used. \\ You can adjust it in the script: * An alternate text for the case that there is no link * the maximum number of characters for the link text * trailing char/string when maximum number of characters is exceeded * Prefix/suffix if no link has been generated //(E.g. in mode :0)//. It is automatically generating CSS classes for the states "no link", "first link" in PREV if the first link is left out, the "last link" in NEXT if if the last link is left out, if it is linked to a category. This TAG replaces the TAG [[english/phpwcms_replacer_rts/frontend_render/xbrowse-up]]. //(Please do not use both at the same time in parallel).// \\ ===== Description: ===== **{XBROWSE:UP:LinkText}** or e.g. **{XBROWSE:UP:^^ | ^^}** \\ * **LinkText** = freely definable link text * **|** = Placeholder for the category titel \\ - Browse up to the category //(article listing)// if the user is in article detail view //(article listing mode set)//. \\ - Browse up to the parent category if the user is in article detail view //(simple article mode)// or category view. **{XBROWSE:PREV:LinkText:2}** or e.g. \\ **{XBROWSE:PREV:<< | <<:2}** or **{XBROWSE:PREV:<< || <<:2}** or **{XBROWSE:PREV:<< | || <<:2}** \\ * **LinkText** = freely definable link text * **|** = Placeholder for the article title in freely definable link text * **||** = Placeholder for the article subtitel in freely definable link text * **:0** = no link branch if start/end article reached * **:1** = link branch to the next article in the next level if start/end article reached * **:2** = link branch to the last/first article if start/end article reached (loop) //(Only in list mode available, otherwise :1)// \\ ==== Parameter in the script: ==== // ************ CUSTOM VAR *********************************************** $up_no_linktext = '--'; // +KH: if no link is available $up_max_char_count = 30; // +KH: max chars in link text $up_max_char_affix = '…'; // +KH: affix if > max_char_count $up_prefix_no_link = ''; $up_sufix_no_link = ''; $next_no_linktext = '--'; // +KH: if no link is available $next_max_char_count = 30; // +KH: max chars in link text $next_max_char_affix = '…'; // +KH: affix if > max_char_count $next_prefix_no_link = ''; $next_sufix_no_link = ''; $prev_no_linktext = '--'; // +KH: if no link is available $prev_max_char_count = 30; // +KH: max chars in link text $prev_max_char_affix = '…'; // +KH: affix if > max_char_count $prev_prefix_no_link = ''; $prev_sufix_no_link = ''; // ************ END CUSTOM VAR ******************************************* \\ ====== ====== This tag can alternatively be used for the built-in [[http://www.phpwcms-docu.de/navigation_tags.phtml|{BROWSE:NEXT/PREV/UP:LinkText}]]. ---- \\ **rt_xbrowse_neprup** V1.0 07.07.2010 Docu: -- \\ Forum: -- **Author:** K.Heermann (flip-flop) http://planmatrix.de \\ **CMS Version:** >= 1.3 \\ **Version:** V1.0 \\ Tag: **{XBROWSE:NEXT/PREV/UP:LinkText}** \\ Fileame: **rt_xbrowse_neprup.php** Folder: ** template/inc_script/frontend_render/ ** **Condition:** -> [[http://www.phpwcms-docu.de/conf_inc_php_en.phtml|/config/phpwcms/conf.inc.php]] \\ * ##$phpwcms['allow_ext_render'] = 1;## ---- ---- \\ ==== Code V1.0: ==== Folder: **template/inc_script/frontend_render/** \\ File: **rt_xbrowse_neprup.php** > | >>:2} ===> Link = ">> article title >>", * loop = last to first article * "Link Text" or | or || * = "Link Text" or "Link article title" or or "Link article subtitle" * 0=off = no jump to the next/prev category if the article is the last/first one * 1=on = next/prev category follows last/first article * 2=loop = last/first article follows first/last article in list mode * * * Filename: rt_xbrowse_neprup.php * Folder: /template/inc_script/frontend_render/ * Switch: $phpwcms['allow_ext_render'] = 1; (/config/phpwcms/conf.inc.php) * * Forum: -- *******************************************************************/ // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- // Tag available // Tag im Content gesetzt? Z.B. {XBROWSE:NEXT:^^^^} if(strpos($content["all"],'{XBROWSE:') !== false) { // ************ CUSTOM VAR *********************************************** $up_no_linktext = '--'; // +KH: if no link is available $up_max_char_count = 30; // +KH: max chars in link text $up_max_char_affix = '…'; // +KH: affix if > max_char_count $up_prefix_no_link = ''; $up_sufix_no_link = ''; $next_no_linktext = '--'; // +KH: if no link is available $next_max_char_count = 30; // +KH: max chars in link text $next_max_char_affix = '…'; // +KH: affix if > max_char_count $next_prefix_no_link = ''; $next_sufix_no_link = ''; $prev_no_linktext = '--'; // +KH: if no link is available $prev_max_char_count = 30; // +KH: max chars in link text $prev_max_char_affix = '…'; // +KH: affix if > max_char_count $prev_prefix_no_link = ''; $prev_sufix_no_link = ''; // ************ END CUSTOM VAR ******************************************* // UP ========================================================== function xget_index_link_up($linktext, $no_linktext, $max_char_count, $max_char_affix,$prefix_no_link,$sufix_no_link) { $link = ''; $cat_id = $GLOBALS['content']["cat_id"]; if (empty($linktext)) $linktext = '^UP^'; // In detail view if article listing mode is set // In der Detailansicht wenn Artikellisten-Modus aktiv if ( empty($GLOBALS['aktion']['3']) ) { // Jump to the category // gehe zur Kategorie $link = $GLOBALS['content']["struct"][$GLOBALS['content']["cat_id"]]["acat_alias"]; $link = ''; // In category view if normal article- or listing mode set // In der Kategorie bei infachem & Artikellisten-Modus } // Jump to parent category // gehe zur Eltern-Kategorie elseif($cat_id && !$GLOBALS['content']['struct'][$cat_id]['acat_hidden']) { $upid = $GLOBALS['content']['struct'][$cat_id]['acat_struct']; $link = ''; $cat_id = $upid; } $linktext = str_replace('||','',$linktext); // +KH // Is there any placeholder in linktext and link available? if (!$link AND strpos($linktext, '|')) $linktext = str_replace('|', $no_linktext, $linktext); // generate the linktext $cat_name = $GLOBALS['content']['struct'][$cat_id]['acat_name']; $linktext = str_replace('|',((strlen($cat_name) > $max_char_count)? substr($cat_name,0,$max_char_count).$max_char_affix: $cat_name), $linktext); // +KH return ($link) ? $link.$linktext.'' : $prefix_no_link.$linktext.$sufix_no_link; } // NEXT ======================================================== function xget_index_link_next($linktext, $cat_down=0, $no_linktext, $max_char_count, $max_char_affix,$prefix_no_link,$sufix_no_link) { global $content; // return the link to next article in current ctageory $a_id = isset($content['article_id']) ? $content['article_id'] : $GLOBALS['aktion'][1]; $linktext = trim($linktext); if(!$linktext) { $linktext = 'NEXT'; $no_linktext = $linktext; } $link = ''; $article = false; // +KH: article mode if(count($content['articles']) > 1) { $c = 0; //temp counter $f = 0; //+KH: temp id for first article foreach($content['articles'] as $key => $value) { if (!$f) $f = $key; // +KH: first article ID if($c || !$a_id) { $link = ''; $article = true; // +KH: article mode break; } if($key == $a_id) $c++; } // +KH: loop is selected and last article in use if ($cat_down == 2 && !$link ) { $key = $f; // set up the right key from first article $article = true; // +KH: article mode $link = ''; // +KH: last article } } if($cat_down && !$link) { // go cat down or to next cat above if($content['cat_id']) { foreach($content['struct'] as $key => $value) { if($content['struct'][$key]['acat_struct'] == $content['cat_id']) { $link = ''; break; } } } else { $c = 0; foreach($content['struct'] as $key => $value) { if($c) { $link = ''; break; } $c++; } } if(!$link && $content['cat_id']) { $c=0; $temp_key = array(); foreach($content['struct'] as $key => $value) { if($content['struct'][$key]['acat_struct'] == $content['struct'][ $content['cat_id'] ]['acat_struct']) { $temp_key[] = $key; } } $count_temp = count($temp_key); if($count_temp) { $c=0; foreach($temp_key as $value) { if($value == $content['cat_id'] && $c+1 < $count_temp) { //$link = ''; $key = $temp_key[$c+1]; $link = ''; break; } $c++; } if($c == $count_temp && !$link) { // back reverese to higher next structure level $current_id = $content['cat_id']; while($c=1) { $parent_id = $content['struct'][ $current_id ]['acat_struct']; $parent_struct_id = $content['struct'][ $parent_id ]['acat_struct']; $c=0; foreach($content['struct'] as $key => $value) { if($content['struct'][$key]['acat_struct'] == $parent_struct_id) { if($c) { $link = ''; break; } if($key == $parent_id) $c=1; } } if(!$parent_struct_id) { if(!$parent_id) $link = ''; break; } else { $current_id = $parent_id; } } } } } } // +KH: replace article title/subtitle if | or || is available if ($link) { if ($article) { $linktext = str_replace('||',((strlen($content['articles'][$key]['article_subtitle']) > $max_char_count)? substr($content['articles'][$key]['article_subtitle'],0,$max_char_count).$max_char_affix: $content['articles'][$key]['article_subtitle']), $linktext); // +KH $linktext = str_replace('|',((strlen($content['articles'][$key]['article_title']) > $max_char_count)? substr($content['articles'][$key]['article_title'],0,$max_char_count).$max_char_affix: $content['articles'][$key]['article_title']), $linktext); // +KH } else { $linktext = str_replace('||','',$linktext); // +KH $linktext = str_replace('|',((strlen($content['struct'][$key]['acat_name']) > $max_char_count)? substr($content['struct'][$key]['acat_name'],0,$max_char_count).$max_char_affix: $content['struct'][$key]['acat_name']), $linktext); // +KH } } else { // Is there any placeholder in linktext? if (strpos($linktext, '|')) { $linktext = str_replace('||', $no_linktext, $linktext); $linktext = str_replace('|', $no_linktext, $linktext); // $linktext = $no_linktext; // +KH: if no link is available } } return ($link) ? $link.$linktext.'' : $prefix_no_link.$linktext.$sufix_no_link; } // PREV ==================================================== function xget_index_link_prev($linktext, $cat_up=0, $no_linktext, $max_char_count, $max_char_affix, $prefix_no_link,$sufix_no_link) { global $content; // return the link to next article in current ctageory $a_id = isset($GLOBALS['content']['article_id']) ? $GLOBALS['content']['article_id'] : $GLOBALS['aktion'][1]; $linktext = trim($linktext); if(!$linktext) { $linktext = 'PREV'; $no_linktext = $linktext; } $link = ''; $article = false; // +KH: article mode $c = 0; //temp counter if(count($GLOBALS['content']['articles']) > 1 && $a_id) { foreach($GLOBALS['content']['articles'] as $key => $value) { if($key == $a_id && $c) { $link = ''; $article = true; // +KH: article mode break; } $c++; $prev_cat_id = $GLOBALS['content']['articles'][$key]['article_cid']; $prev_art_id = $key; } $key =$prev_art_id; // +KH // +KH: loop is selected and first article in use if ($cat_up == 2 && !$link ) { foreach($GLOBALS['content']['articles'] as $key => $value) {} // last artikle key $article = true; // +KH: article mode $link = ''; // +KH: last article link } } if($cat_up && $a_id && $c && !$link) { $link = ''; } if($cat_up && !$link) { // go cat down or to next cat above $temp_key = array(); foreach($GLOBALS['content']['struct'] as $key => $value) { if($GLOBALS['content']['struct'][$key]['acat_struct'] == $GLOBALS['content']['struct'][ $GLOBALS['content']['cat_id'] ]['acat_struct']) { $temp_key[] = $key; } } if(count($temp_key) && $GLOBALS['content']['cat_id']) { $c = 0; foreach($temp_key as $value) { if($value == $GLOBALS['content']['cat_id']) { $prev_cat_id = (!$c) ? $GLOBALS['content']['struct'][$value]['acat_struct'] : $temp_key[$c-1]; $link = ''; break; } $c++; } } } // +KH: replace article title/subtitle if | or || is available if ($link) { if ($article) { $linktext = str_replace('||',((strlen($content['articles'][$key]['article_subtitle']) > $max_char_count)? substr($content['articles'][$key]['article_subtitle'],0,$max_char_count).$max_char_affix: $content['articles'][$key]['article_subtitle']), $linktext); // +KH $linktext = str_replace('|',((strlen($content['articles'][$key]['article_title']) > $max_char_count)? substr($content['articles'][$key]['article_title'],0,$max_char_count).$max_char_affix: $content['articles'][$key]['article_title']), $linktext); // +KH } else { $linktext = str_replace('||','',$linktext); // +KH $linktext = str_replace('|',((strlen($content['struct'][$prev_cat_id]['acat_name']) > $max_char_count)? substr($content['struct'][$prev_cat_id]['acat_name'],0,$max_char_count).$max_char_affix: $content['struct'][$prev_cat_id]['acat_name']), $linktext); // +KH } } else { // Is there any placeholder in linktext? if (strpos($linktext, '|')) { $linktext = str_replace('||', $no_linktext, $linktext); $linktext = str_replace('|', $no_linktext, $linktext); // $linktext = $no_linktext; // +KH: if no link is available } } return ($link) ? $link.$linktext.'' : $prefix_no_link.$linktext.$sufix_no_link; } $content["all"] = preg_replace('/\{XBROWSE:UP:(.*?)\}/e','xget_index_link_up("$1",$up_no_linktext,$up_max_char_count,$up_max_char_affix,$up_prefix_no_link,$up_sufix_no_link);',$content["all"]); $content["all"] = preg_replace('/\{XBROWSE:NEXT:(.*?):(0|1|2)\}/e','xget_index_link_next("$1",$2,$next_no_linktext,$next_max_char_count,$next_max_char_affix,$next_prefix_no_link,$next_sufix_no_link);',$content["all"]); $content["all"] = preg_replace('/\{XBROWSE:PREV:(.*?):(0|1|2)\}/e','xget_index_link_prev("$1",$2,$prev_no_linktext,$prev_max_char_count,$prev_max_char_affix,$prev_prefix_no_link,$prev_sufix_no_link);',$content["all"]); } // END if {XBROWSE: ?> Optional die Home Kategorie ausklammern, siehe 2x **''%%if ($content['cat_id'] == 0 ) ....;%%''** \\