Saerdnaers Topics Order Hack - Nach Bewertung sortieren?
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.0, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Aufsteigend sortiert:
0.00
0.00
0.00
4.00
8.00
Absteigend sortiert:
0.00
0.00
0.00
8.00
4.00
Eigentlich müsste es so sein:
Aufsteigend sortiert:
0.00
0.00
0.00
4.00
8.00
Absteigend sortiert:
8.00
4.00
0.00
0.00
0.00
Kann man das irgendwie hinbekommen?
Grüße JLoop
Code: Alles auswählen
$order_by = "rating $sort_order";
Code: Alles auswählen
$order_by = "IF(rating = NULL, 0, rating) $sort_order";
ersetzen...
ah
viewtopic.php:
suchen:
Code: Alles auswählen
$sort_order = "DESC";
}
Code: Alles auswählen
$toh_sql1 = '';
$toh_sql2 = '';
$toh_sql3 = '';
suchen:
Code: Alles auswählen
case 'time':
$order_by = "t.topic_id $sort_order";
break;
Code: Alles auswählen
case 'rating':
$order_by = "IF(rating = NULL, 0, rating) $sort_order";
$toh_sql1 = ', AVG(rating) AS rating';
$toh_sql2 = 'LEFT JOIN ' . RATE_TABLE . ' r ON r.topic_id = t.topic_id ';
$toh_sql3 = 'GROUP BY t.topic_id, u.user_id, u2.user_id';
break;
Code: Alles auswählen
$mode_types = array("default", [...]
Code: Alles auswählen
$mode_types_text[] = 'Bewertung';
$mode_types[] = 'rating';
Code: Alles auswählen
//
// All announcement data, this keeps announcements
// on each viewforum page ...
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username, pt.post_text
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2, " . POSTS_TEXT_TABLE . " pt
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id
AND p.post_id = pt.post_id
AND p.poster_id = u2.user_id
AND t.topic_type = " . POST_ANNOUNCE . "
ORDER BY $order_by ";
Code: Alles auswählen
pt.post_text
Code: Alles auswählen
$toh_sql1
Code: Alles auswählen
" . POSTS_TEXT_TABLE . " pt
Code: Alles auswählen
$toh_sql2
Code: Alles auswählen
AND t.topic_type = " . POST_ANNOUNCE . "
Code: Alles auswählen
$toh_sql3
Code: Alles auswählen
//
// Grab all the basic data (all topics except announcements)
// for this forum
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND t.topic_type <> " . POST_ANNOUNCE . "
$limit_topics_time
ORDER BY t.topic_type DESC, $order_by
LIMIT $start, ".$board_config['topics_per_page'];
Code: Alles auswählen
p2.post_time
Code: Alles auswählen
$toh_sql1
Code: Alles auswählen
" . USERS_TABLE . " u2
Code: Alles auswählen
$toh_sql2
Code: Alles auswählen
$limit_topics_time
Code: Alles auswählen
$toh_sql3
suchen:
Code: Alles auswählen
//
// All GLOBAL announcement data, this keeps GLOBAL announcements
// on each viewforum page ...
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
WHERE t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id
AND p.poster_id = u2.user_id
AND t.topic_type = " . POST_GLOBAL_ANNOUNCE . "
ORDER BY $order_by ";
Code: Alles auswählen
p.post_username
Code: Alles auswählen
$toh_sql1
Code: Alles auswählen
" . USERS_TABLE . " u2
Code: Alles auswählen
$toh_sql2
Code: Alles auswählen
AND t.topic_type = " . POST_GLOBAL_ANNOUNCE . "
Code: Alles auswählen
$toh_sql3
PS: ich hab den ersten beitrag editert damit man nicht auf alle 3 seiten suchen muss um diese modfikation auch zu machen...
Code: Alles auswählen
## EasyMod 0.0.7 compliant
#################################################################
## MOD Title: Sort Search Results
## MOD Author: Shannado <sven@shannado.nl> (Sven) http://www.shannado.nl/forumorg
## MOD Description: With this MOD an user can sort his/her search results
## MOD Version: 1.0.3
##
## Installation Level: Easy
## Installation Time: 10 - 20 Minutes
## Files To Edit: search.php,
## search_results_posts.tpl,
## search_results_topics.tpl,
## lang_main.php
## Included Files: N/A
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/
##############################################################
##
## Author Note:
##
##############################################################
##
## History:
## ------------
## 0.8.1 beta
## - Beta
##
## 0.8.2 beta
## - Fixed a typo in OPEN - command
## - Made the HOW TO phpBB v2.0.1 compliant
##
## 0.8.3 beta
## - I didn't work well with the Search back MOD of Niels.
##
## 1.0.0 Final
## - Final
##
## 1.0.1 Final
## - Fixed mistakes in the HOW TO
##
## 1.0.2 Final
## - When used the 'newest posts' link on the index
## the pagination & sort did not work well
##
## 1.0.3 FINAL
## - Made phpBB v2.0.2 complaint and EasyMod 0.0.7 complaint
#################################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
#################################################################
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all Folks!
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['Topic_time'] = 'Topic Time';
#
#-----[ OPEN ]------------------------------------------
#
search.php
#
#-----[ FIND ]------------------------------------------
#
$search_forum = ( isset($HTTP_POST_VARS['search_forum']) ) ? intval($HTTP_POST_VARS['search_forum']) : -1;
#
#-----[ REPLACE WITH ]------------------------------------------
#
$search_forum = ( isset($HTTP_GET_VARS['search_forum']) ) ? intval($HTTP_GET_VARS['search_forum']) : (($HTTP_POST_VARS['search_forum'])? intval($HTTP_POST_VARS['search_forum']):-1);
#
#-----[ FIND ]------------------------------------------
#
$sort_by = ( isset($HTTP_POST_VARS['sort_by']) ) ? intval($HTTP_POST_VARS['sort_by']) : 0;
#
#-----[ REPLACE WITH ]------------------------------------------
#
$sort_by = ( isset($HTTP_GET_VARS['sort_by']) ) ? $HTTP_GET_VARS['sort_by'] : (($HTTP_POST_VARS['sort_by'])? $HTTP_POST_VARS['sort_by']: 0);
#
#-----[ FIND ]------------------------------------------
#
if ( isset($HTTP_POST_VARS['sort_dir']) )
{
$sort_dir = ( $HTTP_POST_VARS['sort_dir'] == 'DESC' ) ? 'DESC' : 'ASC';
}
else
{
$sort_dir = 'DESC';
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
if ( isset($HTTP_POST_VARS['sort_dir']) || isset($HTTP_GET_VARS['sort_dir']) )
{
if ( isset($HTTP_POST_VARS['sort_dir']) )
{
$sort_dir = ( $HTTP_POST_VARS['sort_dir'] == 'DESC' ) ? 'DESC' : 'ASC';
}
if ( isset($HTTP_GET_VARS['sort_dir']) )
{
$sort_dir = ( $HTTP_GET_VARS['sort_dir'] == 'DESC' ) ? 'DESC' : 'ASC';
}
}
else
{
$sort_dir = 'DESC';
}
#
#-----[ FIND ]------------------------------------------
#
$sort_by_types = array($lang['Sort_Time'], $lang['Sort_Post_Subject'], $lang['Sort_Topic_Title'], $lang['Sort_Author'], $lang['Sort_Forum']);
#
#-----[ REPLACE WITH ]------------------------------------------
#
$sort_by_types = array($lang['Sort_Time'], $lang['Sort_Post_Subject'], $lang['Sort_Topic_Title'], $lang['Sort_Author'], $lang['Sort_Forum'], $lang['Topic_time'], $lang['Views'], $lang['Replies']);
//
// Sorting Search Results - Begin
//
$mod_sort_by = $sort_by;
$mod_sort_dir = $sort_dir;
$s_sort_by = "";
for($i = 0; $i < count($sort_by_types); $i++)
{
$selected = ( $sort_by == $i ) ? ' selected="selected"' : '';
$s_sort_by .= "<option value=\"" . $i . "\"$selected>" . $sort_by_types[$i] . "</option>";
}
if($sort_dir == 'ASC')
{
$s_sort_dir = '<option value="ASC" selected="selected">' . $lang['Sort_Ascending'] . '</option><option value="DESC">' . $lang['Sort_Descending'] . '</option>';
}
else
{
$s_sort_dir = '<option value="ASC">' . $lang['Sort_Ascending'] . '</option><option value="DESC" selected="selected">' . $lang['Sort_Descending'] . '</option>';
}
//
// Sorting Search Results - END
//
#
#-----[ FIND ]------------------------------------------
#
if ( $row = $db->sql_fetchrow($result) )
{
$search_data = unserialize($row['search_array']);
for($i = 0; $i < count($store_vars); $i++)
{
$$store_vars[$i] = $search_data[$store_vars[$i]];
#
#-----[ AFTER, ADD ]------------------------------------------
#
$sort_by = $mod_sort_by;
$sort_dir = $mod_sort_dir;
#
#-----[ FIND ]------------------------------------------
#
case 4:
$sql .= 'f.forum_id';
break;
#
#-----[ AFTER, ADD ]------------------------------------------
#
case 5:
$sql .= 't.topic_time';
break;
case 6:
$sql .= 't.topic_views';
break;
case 7:
$sql .= 't.topic_replies';
break;
#
#-----[ FIND ]------------------------------------------
#
$base_url = "search.$phpEx?search_id=$search_id";
#
#-----[ REPLACE WITH ]------------------------------------------
#
//
// Sorting Search Results - BEGIN
//
if ( $search_id )
{
$hidden_fields .= '<input type="hidden" name="mode" value="' . ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'] . '" />';
$s_action = append_sid("search.$phpEx?search_id=$search_id");
$base_url = "search.$phpEx?search_id=$search_id&sort_by=$sort_by&sort_dir=$sort_dir";
}
else
{
$hidden_fields .= '<input type="hidden" name="search_id" value="' . $search_id . '" />';
$s_action = append_sid("search.$phpEx?mode=results");
$base_url = "search.$phpEx?search_id=$search_id";
}
$hidden_fields .= '<input type="hidden" name="search_keywords" value="' . ( isset($HTTP_GET_VARS['search_keywords']) ) ? $HTTP_GET_VARS['search_keywords'] : $HTTP_POST_VARS['search_keywords'] . '" />';
$hidden_fields .= '<input type="hidden" name="search_author" value="' . ( isset($HTTP_GET_VARS['search_author']) ) ? $HTTP_GET_VARS['search_author'] : $HTTP_POST_VARS['search_author'] . '" />';
$hidden_fields .= '<input type="hidden" name="show_results" value="' . ( isset($HTTP_GET_VARS['show_results']) ) ? $HTTP_GET_VARS['show_results'] : $HTTP_POST_VARS['show_results'] . '" />';
$hidden_fields .= '<input type="hidden" name="search_terms" value="' . ( isset($HTTP_GET_VARS['search_terms']) ) ? $HTTP_GET_VARS['search_terms'] : $HTTP_POST_VARS['search_terms'] . '" />';
$hidden_fields .= '<input type="hidden" name="search_fields" value="' . ( isset($HTTP_GET_VARS['search_fields']) ) ? $HTTP_GET_VARS['search_fields'] : $HTTP_POST_VARS['search_fields'] . '" />';
$hidden_fields .= '<input type="hidden" name="return_chars" value="' . ( isset($HTTP_GET_VARS['return_chars']) ) ? $HTTP_GET_VARS['return_chars'] : $HTTP_POST_VARS['return_chars'] . '" />';
$hidden_fields .= '<input type="hidden" name="search_cat" value="' . ( isset($HTTP_GET_VARS['search_cat']) ) ? $HTTP_GET_VARS['search_cat'] : $HTTP_POST_VARS['search_cat'] . '" />';
$hidden_fields .= '<input type="hidden" name="search_forum" value="' . ( isset($HTTP_GET_VARS['search_forum']) ) ? $HTTP_GET_VARS['search_forum'] : $HTTP_POST_VARS['search_forum'] . '" />';
$hidden_fields .= '<input type="hidden" name="search_time" value="' . ( isset($HTTP_GET_VARS['search_time']) ) ? $HTTP_GET_VARS['search_time'] : $HTTP_POST_VARS['search_time'] . '" />';
//
// Sorting Search Results - END
//
#
#-----[ FIND ]------------------------------------------
#
'L_POSTED' => $lang['Posted'],
'L_SUBJECT' => $lang['Subject'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
'L_SUBMIT' => $lang['Sort'],
'L_ORDER' => $lang['Order'],
'L_SORT_BY' => $lang['Sort_by'],
'S_SORT_OPTIONS' => $s_sort_by,
'S_SORT_DIR' => $s_sort_dir,
'S_HIDDEN_FIELDS' => $hidden_fields,
'S_SORT_ACTION' => $s_action,
#
#-----[ FIND ]------------------------------------------
#
//
// Sorting
//
$s_sort_by = "";
for($i = 0; $i < count($sort_by_types); $i++)
{
$s_sort_by .= '<option value="' . $i . '">' . $sort_by_types[$i] . '</option>';
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
//
// Sorting
//
//$s_sort_by = "";
//for($i = 0; $i < count($sort_by_types); $i++)
//{
// $s_sort_by .= '<option value="' . $i . '">' . $sort_by_types[$i] . '</option>';
//}
#
#-----[ OPEN ]------------------------------------------
#
templates/SubSilver/search_results_posts.tpl
#
#-----[ FIND ]------------------------------------------
#
<td align="left"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<form action="{S_SORT_ACTION}" method="POST"><td align="right" nowrap="nowrap"><span class="genmed">{L_SORT_BY} <select class="post" name="sort_by">{S_SORT_OPTIONS}</select> {L_ORDER} <select class="post" name="sort_dir">{S_SORT_DIR}</select> {S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{L_SUBMIT}" class="liteoption" /></span></td></form>
#
#-----[ OPEN ]------------------------------------------
#
templates/SubSilver/search_results_topics.tpl
#
#-----[ FIND ]------------------------------------------
#
<td align="left"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td>
#
#-----[ AFTER, ADD ]------------------------------------------
#
<form action="{S_SORT_ACTION}" method="POST"><td align="right" nowrap="nowrap"><span class="genmed">{L_SORT_BY} <select class="post" name="sort_by">{S_SORT_OPTIONS}</select> {L_ORDER} <select class="post" name="sort_dir">{S_SORT_DIR}</select> {S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{L_SUBMIT}" class="liteoption" /></span></td></form>
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
BTW: Hab nochmal ne frage zu dem Addon für den Topics Order Hack die Topics mit Bewertung werden ja nach der höhe der Bewertung sortiert aber wie werden die mit 0.00 sortiert?Normal nach t.topic_last_post_id?