News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Custom Recent Topics Block

Started by Ilkharnos, December 11, 2017, 02:01:23 AM

Previous topic - Next topic

Ilkharnos

Hello,

I have got a custom php code which uses SSI.php functions in order to build a "Recent Topics" list. You choose which topics will be shown by adding their topic ID within an array. I use this code in a "custom php" block in Simple Portal. After I build a recent topics list, when I click on one of the topics, I am redirected to its beginning (first post).

Since I use it as a "Recent Topics" block, I would like to be redirected to its last post when I click on a topic in this list.

For the same reason, I would like to see a new message icon (...language/new.gif) when there is an unread post in these topics, just like the one in the topic list of a board.

I don't know which of the codes should be modified (SSI.php or the custom php code below?) I am not a coder and I have got almost zero knowledge about php or html codes. So, I would be grateful for any help.

NOTE: Simple Portal's own "Recent Posts/Topics" option is of no use to me.

Thank you in advance.

global $smcFunc;

// Array with all the IDs of topics separated by comas
$topics = array(topicID1, topicID2,...);

$shown = array();

foreach($topics as $id) {
    $request = $smcFunc['db_query']('', '
SELECT t.id_first_msg
FROM {db_prefix}topics as t
WHERE t.id_topic = {int:topic}',
array(
'topic' => $id,
)
);
    while ($row = $smcFunc['db_fetch_row']($request))
        $shown[] = $row[0];
    $smcFunc['db_free_result']($request);
}

ssi_fetchPosts($shown);

Ilkharnos

I have found another solution for what I was trying to accomplish. Problem is solved.

Advertisement: