RANDOMCATEGORY_ALIAS/ID

A quite simple solution to show a random category by alias- or id and show the result at the place of the TAGs {RANDOMCATEGORY_ALIAS} / {RANDOMCATEGORY_ID}.



rt_random_category_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

Tag: {RANDOMCATEGORY}

Filename: rt_random_category_alias.php

Folder: template/inc_script/frontend_render/

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

  • $phpwcms['allow_ext_render'] = 1;



Script:

rt_random_category_alias

<?php
 
/**
*********************************************************************************************
* 18.07.10 KH: http://planmatrix.de V1.0
* frontend_render-Script: Random category alias/id
* Update 19.07.2010 KH: Two Tags {RANDOMCATEGORY_ALIAS} and {RANDOMCATEGORY_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"], '{RANDOMCATEGORY_') ) {
 
    $hidden_category = array();  // CUSTOM: All not available categories like 22,47,56,...
 
 
    $id = array_rand ( $content["struct"], 1 );
 
    while ($content["struct"][$id]["acat_hidden"] != 0     OR $content["struct"][$id]["acat_regonly"] != 0
                                                        OR in_array($id, $hidden_category) )
        $id = array_rand ( $content["struct"], 1 );
 
    // Output alias
    $content["all"] = str_replace('{RANDOMCATEGORY_ALIAS}',$content["struct"][$id]["acat_alias"],$content["all"] );
 
    // Output id
    $content["all"] = str_replace('{RANDOMCATEGORY_ID}',$id,$content["all"] );
 
}
 
?>


  • In “$hidden_category” category IDs can be registered, which are excluded from selection. (23,56,74,12,…) do not use apostrophes!
  • If you need the id instead of the alias, please uncomment the line below ”// Output id” and comment the line below ”// Output alias”.
    Update 19.07.2010 KH: Two TAGs {RANDOMCATEGORY_ALIAS} und {RANDOMCATEGORY_ID}.


english/phpwcms_replacer_rts/frontend_render/random-category-alias-id.txt · Last modified: 2010/07/19 07:53 by Knut Heermann (flip-flop)
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