Page 1 of 2

View new post by section

Posted: Wed Feb 05, 2014 2:33 pm
by Triade
I'd like to have a link like

View unanswered posts • View unread posts • View new posts • View active topic

but with topics sorted by forum section.

Someone can help me?

Re: View new post by section

Posted: Wed Feb 05, 2014 3:16 pm
by AmigoJack
Add &sk=f to the URIs, i.e.:

Code: Select all

https://www.phpbb.com/community/search.php?search_id=egosearch&sk=f

Re: View new post by section

Posted: Wed Feb 05, 2014 4:47 pm
by Triade
i tried here

search.php?search_id=newposts&sk=f

but doesn't seem to sort by forum...

Re: View new post by section

Posted: Wed Feb 05, 2014 7:44 pm
by AmigoJack
In that case it first sorts by time, then by forum.

Re: View new post by section

Posted: Wed Feb 05, 2014 7:59 pm
by Triade
There's a way to sort first by forum and after by time?

Re: View new post by section

Posted: Wed Feb 05, 2014 8:03 pm
by AmigoJack
Would you please tell what you precisely want? In your initial post it was "a link like" but not saying for which exactly. Next one "seemed" to not work. The last one would need a MOD (although I'm curious about the sense having a list of new posts not sorted by time). But before I'll give you instructions I want to make sure you don't come up with the next step of one big request.

Re: View new post by section

Posted: Wed Feb 05, 2014 8:36 pm
by Triade
yes sorry.

i want a link thatgive as result "new post" sorted first by forum and second by time.

Example
if i have three forums
forum a
forum b
forum c
on index page i put a "View New posts by section where i find

message x forum a 21.00
message y forum a 20.00
message z forum b 22.00
message s forum b 15.00
message p forum c 23.15

Re: View new post by section

Posted: Wed Feb 05, 2014 9:15 pm
by AmigoJack
Open /search.php and find:

Code: Select all

            case 'newposts':
                $l_search_title = $user->lang['SEARCH_NEW'];
                // force sorting
                $show_results = (request_var('sr', 'topics') == 'posts') ? 'posts' : 'topics';
                $sort_key = 't';
                $sort_dir = 'd';
Change in the last lines t (for topic) and d (descending) to f (for forum) and a (ascending) to change the behaviour of the existing link. If you want your own parallel link it's just a matter of copying the whole block (from case to break) and give it a different label, i.e. case 'newpostsforumsort'.

Re: View new post by section

Posted: Wed Feb 05, 2014 9:53 pm
by Triade
i get this

Code: Select all

SQL ERROR [ mysql4 ]

Unknown column 'f.forum_id' in 'order clause' [1054]

SQL

SELECT t.topic_id FROM phpbb_topics t WHERE t.topic_last_post_time > 1391635750 AND t.topic_moved_id = 0 ORDER BY f.forum_id ASC LIMIT 1001

BACKTRACE

FILE: [ROOT]/includes/db/mysql.php
LINE: 175
CALL: dbal->sql_error()

FILE: [ROOT]/includes/db/mysql.php
LINE: 222
CALL: dbal_mysql->sql_query()

FILE: [ROOT]/includes/db/dbal.php
LINE: 170
CALL: dbal_mysql->_sql_query_limit()

FILE: [ROOT]/search.php
LINE: 491
CALL: dbal->sql_query_limit()
If it can help i have 3.0.10 version of phpbb

Re: View new post by section

Posted: Wed Feb 05, 2014 10:18 pm
by AmigoJack
Tested now: you also need to add this line (preferrably below the one where you changed t to f):

Code: Select all

$sort_by_sql[$sort_key]= 'forum_id'; 

Re: View new post by section

Posted: Wed Feb 05, 2014 10:23 pm
by Triade
i done this:

Code: Select all

case 'newposts':
                $l_search_title = $user->lang['SEARCH_NEW'];
                // force sorting
                $show_results = (request_var('sr', 'topics') == 'posts') ? 'posts' : 'topics';
                $sort_key = 'f';
                $sort_by_sql[$sort_key]= 'forum_id'; 
                $sort_dir = 'a'; 
but now i get this

Code: Select all

SQL ERROR [ mysql4 ]

Column 'forum_id' in order clause is ambiguous [1052]

SQL

SELECT t.*, f.forum_id, f.forum_name, tp.topic_posted, tt.mark_time, ft.mark_time as f_mark_time FROM phpbb_topics t LEFT JOIN phpbb_forums f ON (f.forum_id = t.forum_id) LEFT JOIN phpbb_topics_posted tp ON (tp.user_id = 29 AND t.topic_id = tp.topic_id) LEFT JOIN phpbb_topics_track tt ON (tt.user_id = 29 AND t.topic_id = tt.topic_id) LEFT JOIN phpbb_forums_track ft ON (ft.user_id = 29 AND ft.forum_id = f.forum_id) WHERE t.topic_id IN (73456, 73348, 73320, 71809, 73446, 54283, 73475, 73477, 73318, 73385, 73444, 73460, 71520, 73383) ORDER BY forum_id DESC

BACKTRACE

FILE: [ROOT]/includes/db/mysql.php
LINE: 175
CALL: dbal->sql_error()

FILE: [ROOT]/search.php
LINE: 697
CALL: dbal_mysql->sql_query()

Re: View new post by section

Posted: Thu Feb 06, 2014 7:21 am
by AmigoJack
Undo all changes.

Find:

Code: Select all

            case 'newposts':
                $l_search_title = $user->lang['SEARCH_NEW'];
                // force sorting
                $show_results = (request_var('sr', 'topics') == 'posts') ? 'posts' : 'topics';
                $sort_key = 't';
                $sort_dir = 'd';
                $sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time';
                $sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
Replace with:

Code: Select all

            case 'newposts':
                $l_search_title = $user->lang['SEARCH_NEW'];
                // force sorting
                $show_results = (request_var('sr', 'topics') == 'posts') ? 'posts' : 'topics';
                $sort_key = 't';
                /*** 2014-02-06 BEGIN AmigoJack
                    http://www.phpbb.com/community/viewtopic.php?t=2225741 ***/
                $sort_key= 'f';
                /*** 2014-02-06 END ***/
                $sort_dir = 'd';
                $sort_by_sql['t'] = ($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time';
                $sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
                /*** 2014-02-06 BEGIN AmigoJack
                    http://www.phpbb.com/community/viewtopic.php?t=2225741 ***/
                $sql_sort= preg_replace( '#f\\.forum_id#i', 'forum_id', $sql_sort );
                /*** 2014-02-06 END ***/
Successfully tested.

Re: View new post by section

Posted: Thu Feb 06, 2014 11:11 am
by Triade
It work as a charm! :D
Thank you so much!

Re: View new post by section

Posted: Thu Feb 06, 2014 9:26 pm
by Volksdevil
Hi guys, with the above code change in search.php, what would be the link we would use to view the search result?

Is it:
example.com/search.php?search_id=newposts&sk=f

or simply now:

example.com/search.php?search_id=newposts

Re: View new post by section

Posted: Thu Feb 06, 2014 9:31 pm
by Triade
no, just:
example.com/search.php?search_id=newposts

i maded a new block copying from
case 'newposts':
to
break

and i changed
case 'newposts':
in
case 'forumpost':

in this case the link is
example.com/search.php?search_id=forumpost