Code: Select all
$sql = 'SELECT topic_id FROM ' . TOPICS_TABLE;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrowset($result);
$randtopicid = array_rand($row);
$template->assign_var('RAND_TOPIC_LINK', '<a href="viewtopic.php?t=' . $randtopicid . '">View a random topic</a>');
Code: Select all
display_forums('', $config['load_moderators']);Code: Select all
$act = request_var('act', '');
$template->assign_var('RAND_TOPIC_LINK', '<a href="index.php?act=rand">View a random topic</a>');
if($act == 'rand')
{
$sql = 'SELECT topic_id
FROM ' . TOPICS_TABLE . '
ORDER BY RAND()
LIMIT 1';
$result = $db->sql_query($sql);
$row = $db->sql_fetchfield('topic_id');
redirect('viewtopic.php?t=' . $row);
}
Code: Select all
<li><a href="{U_SEARCH_UNANSWERED}">Code: Select all
<li>{RAND_TOPIC_LINK} • <li><a href="{U_SEARCH_UNANSWERED}">Thanks. I need minimum display 15 topics on the main page.imkingdavid wrote:Hmm... that's not really the purpose of this MOD. This MOD's aim is simply to provide a way for a user to click a link and show up at a random topic. You would need another MOD to do what you're asking.
As far as your request, I'm sure it can be done. I'm not sure exactly how to go about implementing it. And I'm not sure that 50 topics is really a practical number Maybe you meant 5? Or maybe you actually have a reason for needing 50.
In any case, I can look into it, but no promises.
Users browsing this forum: No registered users and 31 guests