I'm trying to edit a phpbb2 portal which has a poll menu which selects the latest poll thread that has been posted in a forum (a forum dedicated to polls and only polls) and shows them on the main page of the portal.
What I wanted it to do was select a poll thread at random and show it on the main page. So all the polls in that forum could be selected at any time, but I also wanted to limit it so it only shows poll threads that have been created in the last month. To avoid really old polls appearing on the main page.
So I want it to select the threads that have been created in the past week and show them randomly on the main page.
I've tried editing it around myself but I haven't gotten anywhere useful, so I'll just post the original portion of code.
//
// Fetch Poll
//
$fetchpoll = phpbb_fetch_poll($CFG['poll_forum']);
if (!empty($fetchpoll))
{
$template->assign_vars(array(
'S_POLL_QUESTION' => $fetchpoll['vote_text'],
'S_POLL_ACTION' => append_sid('posting.'.$phpEx.'?'.POST_TOPIC_URL.'='.$fetchpoll['topic_id']),
'S_TOPIC_ID' => $fetchpoll['topic_id'],
'L_SUBMIT_VOTE' => $lang['Submit_vote'],
'L_LOGIN_TO_VOTE' => $lang['Login_to_vote']
)
);
for ($i = 0; $i < count($fetchpoll['options']); $i++)
{
$template->assign_block_vars('poll_option_row', array(
'OPTION_ID' => $fetchpoll['options'][$i]['vote_option_id'],
'OPTION_TEXT' => $fetchpoll['options'][$i]['vote_option_text'],
'VOTE_RESULT' => $fetchpoll['options'][$i]['vote_result'],
)
);
}
}
else
{
$template->assign_vars(array(
'S_POLL_QUESTION' => $lang['No_poll'],
'DISABLED' => 'disabled="disabled"'
)