This is an old revision of the document!


RANDOMARTICLE_ALIAS/ID

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

  • $phpwcms['allow_ext_render'] = 1;



Script:

rt_random_article_alias

<?php
 
/**
*********************************************************************************************
* 18.07.10 KH: http://planmatrix.de V1.0
* frontend_render-Script: Random article alias/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"] );
 
}
 
?>


  • In “$hidden_article” können Artikel-IDs eingetragen werden, die von der Selektion ausgenommen sind. ('23,56,74,12,…') Hochkommata am Anfang und Ende verwenden!
  • Wenn die ID anstatt des Alias gebraucht wird, bitte die Zeile nach ”// Output id” entkommentieren und die Zeile nach ”// Output alias” kommentieren.

Update 19.07.2010 KH: Zwei TAGs {RANDOMARTICLE_ALIAS} und {RANDOMARTICLE_ID}.

deutsch/ersetzer_rts/frontend_render/random-article-alias-id.1279518113.txt.gz · Last modified: 2018/06/03 18:07 (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