General Community > Scripting Help
order by subject disordered
Anguz:
I modified MessageIndex to sort a certain board by subject, got the code from part of this mod
the problem is that the threads are ordered in a way that seems pretty weird to me.. you can see it here
so I'm asking you, oh so much more knowledged than I, guys :D... what could the problem be? and how should I fix it?
this is the block of code that deals with this:
--- Code: --- // Grab the appropriate topic information
if ($board == 28) # notas y articulos laakademia.com
$ordrsql = 'm.subject DESC' ;
else
$ordrsql = 'm.posterTime DESC' ;
$stickyOrder = ($modSettings['enableStickyTopics'] == 1 ? 't.isSticky DESC,' : '');
$result = mysql_query("
SELECT t.ID_TOPIC
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
WHERE m.ID_MSG=t.ID_LAST_MSG
AND t.ID_BOARD=$currentboard
ORDER BY $stickyOrder $ordrsql
LIMIT $start,$maxindex") or database_error(__FILE__, __LINE__);
$topics = array();
while ($row = mysql_fetch_assoc($result))
$topics[] = $row['ID_TOPIC'];
if (count($topics))
{
$result = mysql_query("
SELECT t.ID_LAST_MSG, t.ID_TOPIC, t.numReplies, t.locked, m.posterName, m.ID_MEMBER, IFNULL(mem.realName, m.posterName) AS posterDisplayName, t.numViews, m.posterTime, m.modifiedTime, t.ID_FIRST_MSG, t.isSticky, t.ID_POLL, m2.posterName as mname, m2.ID_MEMBER as mid, IFNULL(mem2.realName, m2.posterName) AS firstPosterDisplayName, m2.subject as msub, m2.icon as micon, IFNULL(lt.logTime, 0) AS isRead, IFNULL(lmr.logTime, 0) AS isMarkedRead, m2.posterTime AS mtime
FROM {$db_prefix}topics as t, {$db_prefix}messages as m, {$db_prefix}messages as m2
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER=m.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS mem2 ON (mem2.ID_MEMBER=m2.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC=t.ID_TOPIC AND lt.ID_MEMBER=$ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD=$currentboard AND lmr.ID_MEMBER=$ID_MEMBER)
WHERE t.ID_TOPIC IN (" . implode(',', $topics) . ")
AND m.ID_MSG=t.ID_LAST_MSG
AND m2.ID_MSG=t.ID_FIRST_MSG
ORDER BY $stickyOrder $ordrsql") or database_error(__FILE__, __LINE__);
--- End code ---
thanks for your time again :)
[Unknown]:
Freaky. What happens if stickies are off?
-[Unknown]
Anguz:
--- Quote ---Freaky.
--- End quote ---
isn't it? I'm like "wft?" :o
--- Quote ---What happens if stickies are off?
--- End quote ---
what do you mean?
[Unknown]:
I was thinking that maybe $stickyOrder is messing it up somehow.
-[Unknown]
Anguz:
I'll try replacing
--- Code: ---$stickyOrder = ($modSettings['enableStickyTopics'] == 1 ? 't.isSticky DESC,' : '');
--- End code ---
with
--- Code: ---$stickyOrder = '';
--- End code ---
just for testing
although when ordering by dates (like date replied to, or started) it works fine, even with the stickies
Navigation
[0] Message Index
[#] Next page
Go to full version