Is there any way to pull more than just one random story?
I tried messing around with the number in variables but couldn't make it work:
$blocks["random"]["status"] = 2;
$blocks['random']['num'] = 3;
that is what i tried and it didn't pull up 3 random stories
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
Try limit instead of num?
blocks/random/random.php
<?php
if(!defined("_CHARSET")) exit( );
$count = 0;
$content = "";
$use_tpl = isset($blocks['random']['tpl']) && $blocks['random']['tpl'] ? true : false;
$limit = isset($blocks['random']['limit']) && $blocks['random']['limit'] > 0 ? $blocks['random']['limit'] : 1;
$randomquery = dbquery(_STORYQUERY." ORDER BY rand( ) DESC LIMIT $limit");
if($use_tpl && dbnumrows($randomquery) >0) $tpl->newBlock("randomblock");
while($stories = dbassoc($randomquery))
{
if(!isset($blocks['random']['allowtags'])) $stories['summary'] = strip_tags($stories['summary']);
$stories['summary'] = truncate_text(stripslashes($stories['summary']), (isset($blocks['random']['sumlength']) ? $blocks['random']['sumlength'] : 75));
if(!$use_tpl) $content .= "<div class='randomstory'>".title_link($stories)." "._BY." ".author_link($stories)." ".$ratingslist[$stories['rid']]['name']."<br />".$stories['summary']."</div>";
else {
include(_BASEDIR."includes/storyblock.php");
}
}
if($use_tpl && dbnumrows($randomquery) >0) $tpl->gotoBlock("_ROOT");
?>
Line 7 looks like it might control that. It doesn't look like it's one of the options from the admin panel in any case. (It's not in the block's admin.php.) num doesn't appear in either.
It could limit days like with most recent or something though. I haven't tried it so I'm not really sure what it does.
Thanks Lydsie.
I figured if you change the limit from 1 to whatever number is required, that will work, but it is site wide
Now i am trying to replicate the code from recent block into the random block but not really sure what to do with it
tried adding this in
if(isset($blocks['random']['num'])) $randomquery = $blocks['random']['num'];
$limit = isset($blocks['random']['limit']) && $blocks['random']['limit'] > 0 ? $blocks['random']['limit'] : 1;
and the associated lines in variables, but it isnt quite right lol
if i cant get it skin specific, that is not a total loss, but would be good if i could
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
It looks like it's limit. I wouldn't bother replicating recent because it's just the query:
$randomquery = dbquery(_STORYQUERY." ORDER BY rand( ) DESC LIMIT $limit");
To double-check that it works though, try replacing that with this:
;
$randomquery = dbquery(_STORYQUERY." ORDER BY rand( ) DESC LIMIT 5");
... and see what happens?
archive:
site:
Available for skin/mod commission! π
Thanks Elle, that does change the number as well, but it is also sitewide and I am hoping for a skin specific way to control the number of random items, the same way you can control the number of recent or news items in the variables.php file for each skin if they are defined there.
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
In variables.php add:
$blocks['random']['limit'] = 4;
