NAVIGATION
This shows you the differences between two versions of the page.
|
english:phpwcms_replacer_rts:frontend_render:link-article-alias-id [2011/11/28 15:12] Knut Heermann (flip-flop) created |
english:phpwcms_replacer_rts:frontend_render:link-article-alias-id [2018/06/03 18:09] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | {{indexmenu_n>810}} | + | {{indexmenu_n>110}} |
| - | ====== RANDOMARTICLE_ALIAS/ID ====== | + | ====== Quick Article link with ALIAS/ID ====== |
| - | A quite simple solution to show a random article by alias- or id and show the result at the place of the TAGs **{RANDOMARTICLE_ALIAS}** / **{RANDOMARTICLE_ID}**. | + | A single TAG that makes a link, automatically grabs the title of the destination article and insert the title as link text. |
| - | \\ | + | ##**[QIDA|qIDA **article-alias or article-ID**]**## \\ |
| ---- | ---- | ||
| - | **rt_random_article_alias** V1.0 18.07.10 | + | **rt_qida_link_to_article_alias** V1.0b 28.11.2011 |
| Docu: -- \\ | Docu: -- \\ | ||
| - | Forum: [[http://forum.phpwcms.org/viewtopic.php?f=28&t=20397]] | + | Forum: [[http://forum.phpwcms.org/viewtopic.php?p=133283]] |
| **Author:** K.Heermann (flip-flop) http://planmatrix.de \\ | **Author:** K.Heermann (flip-flop) http://planmatrix.de \\ | ||
| **CMS Version:** >= 1.3 \\ | **CMS Version:** >= 1.3 \\ | ||
| - | **Version:** V1.0 \\ | + | **Version:** V1.0b \\ |
| - | TAGs: {RANDOMARTICLE_ALIAS} and {RANDOMARTICLE_ID} \\ | + | TAGs: [QIDA|qIDA article-alias or article-ID] \\ |
| - | Fileiname: **rt_random_article_alias.php** | + | Fileiname: **rt_qida_link_to_article_alias.php** |
| Folder: ** template/inc_script/frontend_render/ ** | Folder: ** template/inc_script/frontend_render/ ** | ||
| Line 40: | Line 40: | ||
| - | <code php |h rt_xida_link_to_article_alias |h > | + | <code php |h rt_qida_link_to_article_alias |h > |
| <?php | <?php | ||
| /** | /** | ||
| ********************************************************************************************* | ********************************************************************************************* | ||
| - | * 28.11.11 KH: http://planmatrix.de V1.0 | + | * 28.11.11 KH: http://planmatrix.de V1.0b |
| * frontend_render-Script: Link to article alias/id | * frontend_render-Script: Link to article alias/id | ||
| * A single tag that makes a link, automatically grabs the title of the destination article | * A single tag that makes a link, automatically grabs the title of the destination article | ||
| - | * and inserts that as the link text | + | * and insert the title as link text |
| - | * TAGs: [XIDA|xIDA article alias/article id] | + | * TAGs: [QIDA|[qIDA article alias|article id] |
| ********************************************************************************************* | ********************************************************************************************* | ||
| */ | */ | ||
| Line 58: | Line 58: | ||
| // ------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------- | ||
| - | // ============= [XIDA] Article | + | // ============= [QIDA] Article |
| - | if (strpos($content["all"], '[XIDA ') != false OR strpos($content["all"], '[xIDA ') != false ) { | + | if (strpos($content["all"], '[QIDA ') != false OR strpos($content["all"], '[qIDA ') != false ) { |
| $hidden_article = ''; // CUSTOM: All not available article like '23,45,78,...' | $hidden_article = ''; // CUSTOM: All not available article like '23,45,78,...' | ||
| - | preg_match_all('/\[XIDA (.*?)\]/im', $content["all"], $match); | + | preg_match_all('/\[QIDA (.*?)\]/im', $content["all"], $match); |
| if ( isset($match['1']) AND !empty($match['1']) ) { // if match found, replace | if ( isset($match['1']) AND !empty($match['1']) ) { // if match found, replace | ||
| + | // Separate IDs and articles TAGs | ||
| $id_i = ''; | $id_i = ''; | ||
| $id_a = ''; | $id_a = ''; | ||
| Line 74: | Line 75: | ||
| // ID or alias input?? // ID oder alias Eingabe???? | // ID or alias input?? // ID oder alias Eingabe???? | ||
| if ((int)$value == $value AND (int)$value != 0) | if ((int)$value == $value AND (int)$value != 0) | ||
| - | $id_i .= $value.','; | + | $id_i .= trim($value).','; |
| else | else | ||
| - | $id_a .= "'".$value."',"; | + | $id_a .= "'".strtolower(trim($value))."',"; |
| + | |||
| } | } | ||
| - | $count = substr_count($id_i, ','); // Count the entries for a better db performance (LIMIT) | + | // Count all possible matches for a better db performance (LIMIT) |
| - | $count = $count + substr_count($id_a, ","); // Count the entries for a better db performance (LIMIT) | + | $count = substr_count($id_i, ','); |
| + | $count = $count + substr_count($id_a, ","); | ||
| $id_i = substr($id_i, 0, -1); // Kill the last sign "," | $id_i = substr($id_i, 0, -1); // Kill the last sign "," | ||
| $id_a = substr($id_a, 0, -1); // Kill the last sign "," | $id_a = substr($id_a, 0, -1); // Kill the last sign "," | ||
| - | + | ||
| + | // fill up the var with minimum content for a right db search | ||
| + | if (empty($id_i)) $id_i = 0; | ||
| + | if (empty($id_a)) $id_a = "'!n00p!'"; | ||
| // Artikel in der DB suchen | // Artikel in der DB suchen | ||
| Line 90: | Line 96: | ||
| $sql = "SELECT article_id, article_cid, article_alias, article_title, article_subtitle "; | $sql = "SELECT article_id, article_cid, article_alias, article_title, article_subtitle "; | ||
| $sql .= "FROM ".DB_PREPEND."phpwcms_article "; | $sql .= "FROM ".DB_PREPEND."phpwcms_article "; | ||
| - | $sql .= "WHERE article_alias IN (".$id_a.") "; | + | $sql .= "WHERE (article_alias IN (".$id_a.") OR article_id IN (".$id_i.")) "; |
| $sql .= "AND article_public=1 AND article_aktiv=1 AND article_deleted=0 "; | $sql .= "AND article_public=1 AND article_aktiv=1 AND article_deleted=0 "; | ||
| $sql .= "AND (article_archive_status=1 AND article_begin<NOW() "; | $sql .= "AND (article_archive_status=1 AND article_begin<NOW() "; | ||
| Line 105: | Line 111: | ||
| $link = '<a href="index.php?'.$value['article_alias'].'" title="'.$value['article_title'].'">'.$value['article_title'].'</a>'; | $link = '<a href="index.php?'.$value['article_alias'].'" title="'.$value['article_title'].'">'.$value['article_title'].'</a>'; | ||
| // Output id link | // Output id link | ||
| - | $content["all"] = str_replace('[XIDA '.$value['article_id'].']',$link, $content["all"] ); | + | $content["all"] = str_replace('[QIDA '.$value['article_id'].']',$link, $content["all"] ); |
| - | $content["all"] = str_replace('[xIDA '.$value['article_id'].']',$link, $content["all"] ); | + | $content["all"] = str_replace('[qIDA '.$value['article_id'].']',$link, $content["all"] ); |
| // Output alias link | // Output alias link | ||
| - | $content["all"] = str_replace('[XIDA '.$value['article_alias'].']',$link, $content["all"] ); | + | $content["all"] = preg_replace('/\[QIDA '.$value['article_alias'].'\]/im',$link, $content["all"] ); |
| - | $content["all"] = str_replace('[xIDA '.$value['article_alias'].']',$link, $content["all"] ); | + | |
| } | } | ||
| else { | else { | ||
| - | $content["all"] = preg_replace('/\[XIDA (.*?)\]/im','[[No Link set!]]', $content["all"] ); | + | $content["all"] = preg_replace('/\[QIDA (.*?)\]/im','[[No Link set!]]', $content["all"] ); |
| } | } | ||
| Line 122: | Line 127: | ||
| \\ | \\ | ||
| - | * In “$hidden_article” article IDs can be registered, which are excluded from selection. ('23,56,74,12,…') please use apostrophes at the beginning and end! | + | * In “$hidden_article” article IDs can be registered, which then will be excluded from selection. //%%('23,56,74,12,...')%% please use apostrophes at the beginning and end!// |
| + | \\ | ||
| \\ | \\ | ||