Differences

This shows you the differences between two versions of the page.

english:phpwcms_replacer_rts:frontend_render:link-article-alias-id [2011/11/28 16:28]
Knut Heermann (flip-flop)
english:phpwcms_replacer_rts:frontend_render:link-article-alias-id [2018/06/03 18:09] (current)
Line 3: Line 3:
====== Quick Article link with ALIAS/ID ====== ====== Quick Article link with ALIAS/ID ======
-A single TAG that makes a link, automatically grabs the title of the destination article and inserts that as the link text. \\+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**]**## \\ ##**[QIDA|qIDA **article-alias or article-ID**]**## \\
---- ----
-**rt_qida_link_to_article_alias** V1.0a 28.11.2011  +**rt_qida_link_to_article_alias** V1.0b 28.11.2011  
Docu: -- \\ Docu: -- \\
Line 16: Line 17:
**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.0a \\+**Version:** V1.0b \\
   
Line 44: Line 45:
/** /**
********************************************************************************************* *********************************************************************************************
-* 28.11.11 KH: http://planmatrix.de V1.0a+* 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: [QIDA|[qIDA article alias/article id]+* TAGs: [QIDA|[qIDA article alias|article id]
********************************************************************************************* *********************************************************************************************
*/ */
Line 67: Line 68:
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 73: 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.") OR article_id IN (".$id_i.") )";+ $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 108: Line 114:
$content["all"] = str_replace('[qIDA '.$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('[QIDA '.$value['article_alias'].']',$link, $content["all"] ); + $content["all"] = preg_replace('/\[QIDA '.$value['article_alias'].'\]/im',$link, $content["all"] );
- $content["all"] = str_replace('[qIDA '.$value['article_alias'].']',$link, $content["all"] );+
} }
else { else {
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!//
 +\\
\\ \\
english/phpwcms_replacer_rts/frontend_render/link-article-alias-id.1322494136.txt.gz · Last modified: 2018/06/03 18:08 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0