Search Results?

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Scam Warning
Post Reply
User avatar
CGI1984
Registered User
Posts: 167
Joined: Thu Feb 20, 2020 8:27 am

Search Results?

Post by CGI1984 »

Is there any way to change the default search results from displaying only 5 results per page up to 10 results per page? Thanks.
User avatar
tbackoff
Former Team Member
Posts: 7064
Joined: Thu Jun 04, 2009 1:41 am
Location: cheerleading practice
Name: Tabitha Backoff

Re: Search Results?

Post by tbackoff »

Doesn't that go by the posts/topics per page settings?
Flying is the second best thrill to cheerleaders; being caught is the first.
User avatar
CGI1984
Registered User
Posts: 167
Joined: Thu Feb 20, 2020 8:27 am

Re: Search Results?

Post by CGI1984 »

Could be, thanks. I’ll take a look.

Edit:

Yes, that does it, but now I got 10 posts per page too, which I don't want. I liked it at 5. I would prefer 5 posts per page and 10 search results per page, but no way to separate in ACP. I was hoping maybe I could make a small code edit to just change the post per page on search results.
User avatar
AmigoJack
Registered User
Posts: 5743
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Search Results?

Post by AmigoJack »

Keep in mind that a board search can result in posts or topics and either sticks to its setting, not both at one.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
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.
User avatar
EA117
Registered User
Posts: 1681
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Search Results?

Post by EA117 »

CGI1984 wrote:
Wed Apr 15, 2020 12:38 pm
I was hoping maybe I could make a small code edit to just change the post per page on search results.
In phpBB 3.3.0, around line 545 in search.php you'll find:

Code: Select all

	// show_results should not change after this
	$per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page'];
The same line in phpBB 3.2.9 is around line 535. This is where search is defaulting to whatever the normal non-search "posts per page" and "topics per page" configuration is. You can replace those with your own hard-coded defaults instead of reading the configured values, such as:

Code: Select all

	// show_results should not change after this
	$per_page = ($show_results == 'posts') ? '10' : '15';
Or if you just want it to be 10 regardless, simply $per_page = '10';

Normal caveats about how you'll potentially lose this change every time phpBB is updated and will have to re-implement it, etc.
User avatar
CGI1984
Registered User
Posts: 167
Joined: Thu Feb 20, 2020 8:27 am

Re: Search Results?

Post by CGI1984 »

EA117 wrote:
Wed Apr 15, 2020 3:12 pm
CGI1984 wrote:
Wed Apr 15, 2020 12:38 pm
I was hoping maybe I could make a small code edit to just change the post per page on search results.
In phpBB 3.3.0, around line 545 in search.php you'll find:

Code: Select all

	// show_results should not change after this
	$per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page'];
The same line in phpBB 3.2.9 is around line 535. This is where search is defaulting to whatever the normal non-search "posts per page" and "topics per page" configuration is. You can replace those with your own hard-coded defaults instead of reading the configured values, such as:

Code: Select all

	// show_results should not change after this
	$per_page = ($show_results == 'posts') ? '10' : '15';
Or if you just want it to be 10 regardless, simply $per_page = '10';

Normal caveats about how you'll potentially lose this change every time phpBB is updated and will have to re-implement it, etc.
Excellent, thank you so much. Perfect! It was on line 545 as you said (3.3.0).

I went with as you suggested:

Code: Select all

// show_results should not change after this
	$per_page = '10';
Problem solved!
Post Reply

Return to “phpBB Discussion”