Trustmaster |
|
---|---|
Actually the way sticky/lock/annoucnement is designed, you can't do it with a simple query because if you use:
$sql = sed_sql_query("SELECT t.*, p.poll_id FROM $db_forum_topics AS t LEFT JOIN
$db_polls AS p ON t.ft_id=p.poll_code WHERE t.ft_sectionid='$s' $cond AND (p.poll_type='forum' OR p.poll_id IS NULL)
ORDER by ft_sticky DESC, ft_lock DESC, ft_".$o." ".$w."
LIMIT $d, ".$cfg['maxtopicsperpage']); $sql = sed_sql_query("(SELECT t.*, p.poll_id FROM $db_forum_topics AS t LEFT JOIN
$db_polls AS p ON t.ft_id=p.poll_code WHERE t.ft_sectionid='$s' $cond AND (p.poll_type='forum' OR p.poll_id IS NULL)
AND t.ft_sticky = 1 AND t.ft_state = 1
ORDER by ft_".$o." ".$w.")
UNION
(SELECT t.*, p.poll_id FROM $db_forum_topics AS t LEFT JOIN
$db_polls AS p ON t.ft_id=p.poll_code WHERE t.ft_sectionid='$s' $cond AND (p.poll_type='forum' OR p.poll_id IS NULL)
AND t.ft_sticky = 1 AND t.ft_state = 0
ORDER by ft_".$o." ".$w.")
UNION
(SELECT t.*, p.poll_id FROM $db_forum_topics AS t LEFT JOIN
$db_polls AS p ON t.ft_id=p.poll_code WHERE t.ft_sectionid='$s' $cond AND (p.poll_type='forum' OR p.poll_id IS NULL)
AND t.ft_sticky = 0 AND t.ft_state = 0
ORDER by ft_".$o." ".$w.")
UNION
(SELECT t.*, p.poll_id FROM $db_forum_topics AS t LEFT JOIN
$db_polls AS p ON t.ft_id=p.poll_code WHERE t.ft_sectionid='$s' $cond AND (p.poll_type='forum' OR p.poll_id IS NULL)
AND t.ft_sticky = 0 AND t.ft_state = 1
ORDER by ft_".$o." ".$w.")
LIMIT $d, ".$cfg['maxtopicsperpage']); The last one will work for you, but speed is the price. Added 3 minutes later: And you could do it without a corehack, with a plugin:
<?php
/* ====================
[BEGIN_SED_EXTPLUGIN]
Code=ft_order
Part=topics
File=ft_order.topics
Hooks=forums.topics.main
Tags=
Order=10
[END_SED_EXTPLUGIN]
==================== */
if (!defined('SED_CODE')) { die("Wrong URL."); }
$sql = sed_sql_query("(SELECT t.*, p.poll_id FROM $db_forum_topics AS t LEFT JOIN
$db_polls AS p ON t.ft_id=p.poll_code WHERE t.ft_sectionid='$s' $cond AND (p.poll_type='forum' OR p.poll_id IS NULL)
AND t.ft_sticky = 1 AND t.ft_state = 1
ORDER by ft_".$o." ".$w.")
UNION
(SELECT t.*, p.poll_id FROM $db_forum_topics AS t LEFT JOIN
$db_polls AS p ON t.ft_id=p.poll_code WHERE t.ft_sectionid='$s' $cond AND (p.poll_type='forum' OR p.poll_id IS NULL)
AND t.ft_sticky = 1 AND t.ft_state = 0
ORDER by ft_".$o." ".$w.")
UNION
(SELECT t.*, p.poll_id FROM $db_forum_topics AS t LEFT JOIN
$db_polls AS p ON t.ft_id=p.poll_code WHERE t.ft_sectionid='$s' $cond AND (p.poll_type='forum' OR p.poll_id IS NULL)
AND t.ft_sticky = 0 AND t.ft_state = 0
ORDER by ft_".$o." ".$w.")
UNION
(SELECT t.*, p.poll_id FROM $db_forum_topics AS t LEFT JOIN
$db_polls AS p ON t.ft_id=p.poll_code WHERE t.ft_sectionid='$s' $cond AND (p.poll_type='forum' OR p.poll_id IS NULL)
AND t.ft_sticky = 0 AND t.ft_state = 1
ORDER by ft_".$o." ".$w.")
LIMIT $d, ".$cfg['maxtopicsperpage']);
?> Added 5 minutes later: And here is your ft_order plugin. I hope it is a good lesson to everyone here. Have a nice day. May the Source be with you!
|
|
This post was edited by Trustmaster (2009-07-20 21:36, 14 years ago) |