NAVIGATION
This is an old revision of the document!
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}.
rt_random_article_alias V1.0 18.07.10
Docu: –
Forum: http://forum.phpwcms.org/viewtopic.php?f=28&t=20397
Author: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.3
Version: V1.0
TAGs: {RANDOMARTICLE_ALIAS} and {RANDOMARTICLE_ID}
Fileiname: rt_random_article_alias.php
Folder: template/inc_script/frontend_render/
Condition: → /config/phpwcms/conf.inc.php
<?php /** ********************************************************************************************* * 28.11.11 KH: http://planmatrix.de V1.0 * frontend_render-Script: Link to article alias/id * A single tag that makes a link, automatically grabs the title of the destination article * and inserts that as the link text * TAGs: [XIDA|xIDA article alias/article id] ********************************************************************************************* */ // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ------------------------------------------------------------------------------------------- // ============= [XIDA] Article if (strpos($content["all"], '[XIDA ') != false OR strpos($content["all"], '[xIDA ') != false ) { $hidden_article = ''; // CUSTOM: All not available article like '23,45,78,...' preg_match_all('/\[XIDA (.*?)\]/im', $content["all"], $match); if ( isset($match['1']) AND !empty($match['1']) ) { // if match found, replace $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 .= $value.','; else $id_a .= "'".$value."',"; } $count = substr_count($id_i, ','); // Count the entries for a better db performance (LIMIT) $count = $count + substr_count($id_a, ","); // Count the entries for a better db performance (LIMIT) $id_i = substr($id_i, 0, -1); // Kill the last sign "," $id_a = substr($id_a, 0, -1); // Kill the last sign "," // 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.") "; $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('[XIDA '.$value['article_id'].']',$link, $content["all"] ); $content["all"] = str_replace('[xIDA '.$value['article_id'].']',$link, $content["all"] ); // Output alias link $content["all"] = str_replace('[XIDA '.$value['article_alias'].']',$link, $content["all"] ); $content["all"] = str_replace('[xIDA '.$value['article_alias'].']',$link, $content["all"] ); } else { $content["all"] = preg_replace('/\[XIDA (.*?)\]/im','[[No Link set!]]', $content["all"] ); } } // END ( isset($match['1']) } ?>