Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Remaker - joulukuu 07, 2005, 12:42:18 IP

Otsikko: [HELP]ssi_boardnews. How to make sticky topics stay on top of normal topics?
Kirjoitti: Remaker - joulukuu 07, 2005, 12:42:18 IP
Hi!

It seems that sticky topics are not really sticky when you use ssi_boardnews to get the latest topics in a board and I need them to stay on top of a normal topic...
Anyone know what to make sticky topics stay on top of the others?

Thanks in advance.
Otsikko: Re: [HELP]ssi_boardnews. How to make sticky topics stay on top of normal topics?
Kirjoitti: kegobeer - joulukuu 07, 2005, 08:54:51 IP
Well, technically speaking a sticky topic is not necessarily the latest topic on a board, so boardNews is working as expected.  It may be possible, but I wouldn't muck around with boardNews - I'd copy that function, name it something else, and then experiment with it.

I'm sure you could either modify the query grabbing topics to also look for sticky topics, or just add another query that looks just for sticky topics.  I don't have any time to look into the code, but this should give you something to start with.
Otsikko: Re: [HELP]ssi_boardnews. How to make sticky topics stay on top of normal topics?
Kirjoitti: Remaker - joulukuu 08, 2005, 12:25:37 AP
I hoped this could be done without a modification to the ssi. :)
But, I'll do like you said, create a work-around function specific for sticky topics.

Thanks.
Otsikko: Re: [HELP]ssi_boardnews. How to make sticky topics stay on top of normal topics?
Kirjoitti: Remaker - tammikuu 06, 2006, 09:58:59 AP
For anyone interested I managed to make sticky topics stay on top of normal
topics when using ssi_boardnews.

Very simple actually.
I've copied the original function and renamed to ssi_boardnewss and changed a litte in
the database query... as->

This:

// Find the posts.
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_BOARD = $board
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY m.ID_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);


To this:


// Find the posts.
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG, t.locked
FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_FIRST_MSG IN (" . implode(', ', $posts) . ")
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG,t.isSticky DESC
LIMIT " . count($posts), __FILE__, __LINE__);