Ein einfacher TAG der einen Link aufgrund der/s Artikel-ID/Alias erzeugt, welcher automatisch den Titel des Artikels als Linktext verwendet.
[QIDA|qIDA Artikel-Alias oder Artikel-ID]
rt_qida_link_to_article_alias V1.0b 28.11.2011
Docu: –
Forum: http://forum.phpwcms.org/viewtopic.php?p=133283
Autor: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.3
Version: V1.0b
TAGs: [QIDA|qIDA Artikel-Alias oder Artikel-ID]
Dateiname: rt_qida_link_to_article_alias.php
Verzeichnis: template/inc_script/frontend_render/
Bedingung: → /config/phpwcms/conf.inc.php
<?php /** ********************************************************************************************* * 28.11.11 KH: http://planmatrix.de V1.0b * frontend_render-Script: Link to article alias/id * A single tag that makes a link, automatically grabs the title of the destination article * and insert the title as link text * TAGs: [QIDA|[qIDA article alias|article id] ********************************************************************************************* */ // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ------------------------------------------------------------------------------------------- // ============= [QIDA] Article if (strpos($content["all"], '[QIDA ') != false OR strpos($content["all"], '[qIDA ') != false ) { $hidden_article = ''; // CUSTOM: All not available article like '23,45,78,...' preg_match_all('/\[QIDA (.*?)\]/im', $content["all"], $match); if ( isset($match['1']) AND !empty($match['1']) ) { // if match found, replace // Separate IDs and articles TAGs $id_i = ''; $id_a = ''; foreach ($match['1'] as $key=>$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 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_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 // Search for the article in dba $sql = "SELECT article_id, article_cid, article_alias, article_title, article_subtitle "; $sql .= "FROM ".DB_PREPEND."phpwcms_article "; $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_archive_status=1 AND article_begin<NOW() "; $sql .= "OR article_archive_status=0 AND article_end>NOW()) "; $sql .= (!empty($hidden_article))? "AND article_id NOT IN (".$hidden_article.") ":''; $sql .= " LIMIT 0,".$count; $result = _dbQuery($sql); if ($result) foreach ($result as $key=>$value) { // Setup the link $link = '<a href="index.php?'.$value['article_alias'].'" title="'.$value['article_title'].'">'.$value['article_title'].'</a>'; // Output id link $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 $content["all"] = preg_replace('/\[QIDA '.$value['article_alias'].'\]/im',$link, $content["all"] ); } else { $content["all"] = preg_replace('/\[QIDA (.*?)\]/im','[[No Link set!]]', $content["all"] ); } } // END ( isset($match['1']) } ?>