NAVIGATION
Eine einfache Lösung für die zufällige Auswahl einer/s Artikel-Alias- oder id und der Darstellung an der Stelle der 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
Autor: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.3
Version: V1.0
TAGs: {RANDOMARTICLE_ALIAS} und {RANDOMARTICLE_ID}
Dateiname: rt_random_article_alias.php
Verzeichnis: template/inc_script/frontend_render/
Bedingung: → /config/phpwcms/conf.inc.php
<?php /** ********************************************************************************************* * 18.07.10 KH: http://planmatrix.de V1.0 * frontend_render-Script: Random article alias/id * TAGs: {RANDOMARTICLE_ALIAS} and {RANDOMARTICLE_ID} ********************************************************************************************* */ // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ------------------------------------------------------------------------------------------- if (strpos($content["all"], '{RANDOMARTICLE_') ) { $hidden_article = ''; // CUSTOM: All not available article like '23,45,78,...' $c = 0; while ($c == 0) { // Artikel in der DB suchen // Search for the article in dba $sql = "SELECT article_id, article_cid, article_alias "; $sql .= "FROM ".DB_PREPEND."phpwcms_article "; $sql .= "WHERE 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 .= "ORDER BY RAND() LIMIT 0,1"; $result = _dbQuery($sql); if (!$content["struct"][$result['0']['article_cid']]['acat_regonly']) $c = 1; // Break if the category is free for all } // --- END while // Output alias $content["all"] = str_replace('{RANDOMARTICLE_ALIAS}',$result['0']['article_alias'],$content["all"] ); // Output id $content["all"] = str_replace('{RANDOMARTICLE_ID}',$result['0']['article_id'],$content["all"] ); } ?>
Update 19.07.2010 KH: Zwei TAGs {RANDOMARTICLE_ALIAS} und {RANDOMARTICLE_ID}.