{{indexmenu_n>110}} ====== Quick Category link with ALIAS/ID ====== A single TAG that makes a link, automatically grabs the title of the destination category and insert the name as link text. ##**[QIDC|qIDC **category-alias or category-ID**]**## \\ ---- **rt_qidc_link_to_category_alias** V1.0 29.11.2011 Docu: -- \\ Forum: [[http://forum.phpwcms.org/viewtopic.php?p=133283]] **Author:** K.Heermann (flip-flop) http://planmatrix.de \\ **CMS Version:** >= 1.3 \\ **Version:** V1.0 \\ TAGs: [QIDC|qIDC category-alias or category-ID] \\ Fileiname: **rt_qidc_link_to_category_alias.php** Folder: ** template/inc_script/frontend_render/ ** **Condition:** -> [[http://www.phpwcms-docu.de/config_dateien.phtml|/config/phpwcms/conf.inc.php]] \\ * $phpwcms['allow_ext_render'] = 1; ---- ---- \\ ===== Script: ===== $value) { // ID or alias input?? // ID oder alias Eingabe???? if ((int)$value == $value AND (int)$value != 0) $id_i[] = trim($value); else $id_a[] = strtolower(trim($value)); } // Count all possible matches for a better performance in loop $count = count($id_i); $count = $count + count($id_a); // ID based search if (isset($id_i[0])) { // Is there any TAG using IDs? foreach ( $id_i as $key=>$value) { // Looking for all tagged IDs if (array_key_exists($value, $content["struct"]) AND // Looking for the tagged IDs in structure tree $content["struct"][$value]["acat_regonly"] == 0 AND // for registered user only $content["struct"][$value]["acat_hidden"] == 0 AND // category hidden? !in_array($value, $hidden_category) ) { // custom category hidden? // Replace in content $link = ''.$content["struct"][$value]['acat_name'].''; $content["all"] = str_replace('[QIDC '.$value.']',$link, $content["all"] ); $content["all"] = str_replace('[qIDC '.$value.']',$link, $content["all"] ); $count--; } } } // article based search if (isset($id_a[0])) { // Is there any TAG using IDs? foreach ( $content["struct"] as $key=>$value) { // Looking for all tagged IDs if (in_array($value['acat_alias'],$id_a) AND // Looking for all tagged IDs $content["struct"][$key]["acat_regonly"] == 0 AND // for registered user only $content["struct"][$key]["acat_hidden"] == 0 AND // category hidden? !in_array($value['acat_alias'], $hidden_category) ) { // custom category hidden? // Replace in content $link = ''.$content["struct"][$key]['acat_name'].''; $content["all"] = preg_replace('/\[QIDC '.$content["struct"][$key]['acat_alias'].'\]/im',$link, $content["all"] ); // Faster solution: If no match is possible -> break the loop $count--; if ($count == 0) break; } } } if ($count > 0) // If no match kill the rest $content["all"] = preg_replace('/\[QIDC (.*?)\]/im','[[No Link set!]]', $content["all"] ); } // END ( isset($match['1']) } ?> \\ * In "$hidden_category" category IDs can be registered, which then will be excluded from selection. //%%('23,56,74,12,...')%% //. \\