Random from only on...
 
Notifications
Clear all

Random from only one category

3 Posts
2 Users
0 Reactions
1,523 Views
(@jacci)
Posts: 503
Honorable Member
Topic starter
 

Is it possible to duplicate the random block so that it works, but only pulls stories from a single category? So that it works as well as the normal random function... or instead of the normal random function?


why is nothing ever easy?
url: http://www.pretendercentre.com/missingpieces/     
php: 5.2.5  msql: 5.0.45-community
efic version: 3.4.3           latest patches: yes
bridges: none              mods: challenges, displayword, beta-search

 
Posted : 10/05/2011 10:19 pm
(@lyndsie)
Posts: 1263
Member Moderator
 

I bet it's fairly simple. You'll probably need to change this line in random.php:


$randomquery = dbquery(_STORYQUERY." ORDER BY rand( ) DESC LIMIT $limit");

Maybe try...


$randomquery = dbquery(_STORYQUERY." AND stories.catid = X ORDER BY rand( ) DESC LIMIT $limit");

Where X is the ID of the category in question.

To make it a separate block you just have to rename the blocks folder and change all the arrays like $blocks['random'] to a new name, as well as the .tpl outputs from {random}


 
Posted : 10/05/2011 10:41 pm
(@jacci)
Posts: 503
Honorable Member
Topic starter
 

Thanks so much Lyndsie, that worked a treat.

I will try looking at duplicating the block later and report back.


why is nothing ever easy?
url: http://www.pretendercentre.com/missingpieces/     
php: 5.2.5  msql: 5.0.45-community
efic version: 3.4.3           latest patches: yes
bridges: none              mods: challenges, displayword, beta-search

 
Posted : 10/05/2011 11:36 pm
Share: