This is an old revision of the document!


RANDOMCATEGORY

A quite simple solution to show Shows a random category alias- or id and show the result at the place of the tag {RANDOMCATEGORY}.


rt_random_category V1.0 18.07.10

Docu: –
Forum: http://forum.phpwcms.org/viewtopic.php?p=114312#p114312

Autor: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.3
Version: V1.0

Tag: {RANDOMCATEGORY}

Filename: rt_random_category.php

Folder: template/inc_script/frontend_render/

Condition:/config/phpwcms/conf.inc.php

  • $phpwcms['allow_ext_render'] = 1;



Script:

rt_random_category

<?php
 
/**
*********************************************************************************************
* 18.07.10 KH: http://planmatrix.de V1.1
* frontend_render-Script: Random category alias/id
*********************************************************************************************
*/
// -------------------------------------------------------------------------------------------
// obligate check for phpwcms constants
   if (!defined('PHPWCMS_ROOT')) {
      die("You Cannot Access This Script Directly, Have a Nice Day."); }
// -------------------------------------------------------------------------------------------
 
$id = array_rand ( $content["struct"], 1 );
 
while ($content["struct"][$id]["acat_hidden"] != 0)
    $id = array_rand ( $content["struct"], 1 );
 
// Output alias
$content["all"] = str_replace('{RANDOMCATEGORY}',$content["struct"][$id]["acat_alias"],$content["all"] );
 
// Output id
// $content["all"] = str_replace('{RANDOMCATEGORY}',$id,$content["all"] );
?>

If you need the id instead of the alias, please uncomment the line behind // Output id and comment the line behind // Output alias.

english/phpwcms_replacer_rts/frontend_render/random-category-alias-id.1279452731.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