View new post by section

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Get Involved
Triade
Registered User
Posts: 13
Joined: Wed Jan 22, 2014 2:57 pm

View new post by section

Post 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?
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: View new post by section

Post 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
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Triade
Registered User
Posts: 13
Joined: Wed Jan 22, 2014 2:57 pm

Re: View new post by section

Post by Triade »

i tried here

search.php?search_id=newposts&sk=f

but doesn't seem to sort by forum...
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: View new post by section

Post by AmigoJack »

In that case it first sorts by time, then by forum.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Triade
Registered User
Posts: 13
Joined: Wed Jan 22, 2014 2:57 pm

Re: View new post by section

Post by Triade »

There's a way to sort first by forum and after by time?
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: View new post by section

Post 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.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Triade
Registered User
Posts: 13
Joined: Wed Jan 22, 2014 2:57 pm

Re: View new post by section

Post 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
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: View new post by section

Post 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'.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Triade
Registered User
Posts: 13
Joined: Wed Jan 22, 2014 2:57 pm

Re: View new post by section

Post 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
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: View new post by section

Post 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'; 
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Triade
Registered User
Posts: 13
Joined: Wed Jan 22, 2014 2:57 pm

Re: View new post by section

Post 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()
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: View new post by section

Post 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.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Triade
Registered User
Posts: 13
Joined: Wed Jan 22, 2014 2:57 pm

Re: View new post by section

Post by Triade »

It work as a charm! :D
Thank you so much!
User avatar
Volksdevil
Registered User
Posts: 2415
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil
Contact:

Re: View new post by section

Post 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
My phpBB Extensions
Finally found great Website Hosting from :arrow: KUALO!
Do NOT use 123-reg.co.uk - Incapable of running phpBB!
:ugeek: TekNeil - Streamer on Twitch | My Volkswagen Corrado G60
Triade
Registered User
Posts: 13
Joined: Wed Jan 22, 2014 2:57 pm

Re: View new post by section

Post 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
Locked

Return to “[3.0.x] MOD Requests”