Forum Based 'Posts Per Page' [In Dev]

Looking for an Extension? Have an Extension request? Post your request here for help. (Note: This forum is community supported; while there is an Extensions Development Team, said team does not dedicate itself to handling requests in this forum)
Scam Warning
User avatar
Volksdevil
Registered User
Posts: 2415
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil

Forum Based 'Posts Per Page' [In Dev]

Post by Volksdevil »

Edit: Now in Dev thanks to Rich at viewtopic.php?f=456&t=2278686

I'd like to see a port of the mod that I previously used. https://www.phpbb.com/customise/db/mod/ ... _per_page/

It's pretty important as I used it in a forum where the topics tend to have lots of pictures, so I reduced the posts per page down to 5. This means that google etc indexed the pages like that, so for 3.1 I need to keep the same format if possible.

Or should the actual mod be ok if applied to 3.1? :oops:
Last edited by Volksdevil on Tue Dec 02, 2014 7:12 pm, edited 1 time in total.
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
User avatar
Volksdevil
Registered User
Posts: 2415
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil

Re: Forum Based 'Posts Per Page'

Post by Volksdevil »

Bump for any interest.
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
User avatar
Volksdevil
Registered User
Posts: 2415
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil

Re: Forum Based 'Posts Per Page'

Post by Volksdevil »

Bump, just gone to see if the original MOD would be compatible and sadly not :cry: Missing the find $per_page = ($config['posts_per_page'] <= 0) ? 1 : $config['posts_per_page']; in includes/functions_display.php

Hope somebody can make this happen :)
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
marcovo
Registered User
Posts: 239
Joined: Fri Nov 16, 2012 12:19 pm
Location: The Netherlands
Name: Marco

Re: Forum Based 'Posts Per Page'

Post by marcovo »

You can't find it because the function topic_generate_pagination() that was used in phpBB 3.0, doesn't exist any more in phpBB 3.1, and is replaced by the more general pagination creator. It might be possible to create a hackish extension for this (modifying $config['posts_per_page'] each time a specific event is called...), but I guess this should actually be implemented in the core?
Last edited by marcovo on Wed Nov 19, 2014 12:47 pm, edited 1 time in total.
leschek
Registered User
Posts: 861
Joined: Tue Jul 18, 2006 12:49 pm

Re: Forum Based 'Posts Per Page'

Post by leschek »

I also would like to have this one.
User avatar
Volksdevil
Registered User
Posts: 2415
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil

Re: Forum Based 'Posts Per Page'

Post by Volksdevil »

marcovo wrote:but I guess this should actually be implemented in the core?
Ideally yes :) Especially as the option is there for 'Topics per page'. It's a shame the old MOD won't work as that's the only 'find' that can't be found, everything else would have worked out I think :cry:

I'd really like to see this done somehow though, even more so now that I've gone and put the 3.1.1 live because I couldn't wait any longer. :oops: Search engines will be wondering what's going on with all the different pagination, not good!
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
User avatar
Volksdevil
Registered User
Posts: 2415
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil

Re: Forum Based 'Posts Per Page'

Post by Volksdevil »

Bump! Desperately need this :cry:

The old MOD just added an option 'Posts per page' within each forum under the core 'Topics per page'. I hope somebody can throw something together.

I've even had a look at how to make an extension myself but I'm completely lost at the first hurdle. Only wish I had the time to learn. :cry:
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
User avatar
potku
Registered User
Posts: 981
Joined: Wed Dec 22, 2004 10:26 pm
Location: Tampere, Finland

Re: Forum Based 'Posts Per Page'

Post by potku »

We have this MOD, so it would be nice to have this EXT once we migrate.
Potku.net

"Before I speak, I have something important to say."

- Groucho Marx
User avatar
Volksdevil
Registered User
Posts: 2415
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil

Re: Forum Based 'Posts Per Page'

Post by Volksdevil »

EDIT: Had to remove the edit to search.php as active topics was only displaying a single topic. :cry:

I need this so badly that I went ahead and applied the old mod :oops: SQL query and all, all except the one find/add code for includes/functions_display.php

Seems OK'ish...
When viewing a topic, the number of posts displayed is correct (5 as set by me in ACP) and the pagination is OK. But when viewing the actual forum where that topic is, the pagination isn't correct. See pic:

Image


This is the only part of the old mod I had to leave out.
Open: includes/functions_display.php

Find: $per_page = ($config['posts_per_page'] <= 0) ? 1 : $config['posts_per_page'];

Add after:

Code: Select all

// Begin : Forum Based Posts Per Page
	global $posts_num, $u_forum_id, $forum_posts_per_page;
	
	if ($posts_num != 0)
	{
		$per_page = ($posts_num <= 0) ? 1 : $posts_num;
	}
	else if (isset($forum_posts_per_page[$u_forum_id]))
	{
		$per_page = ($forum_posts_per_page[$u_forum_id] == 0) ? $per_page : $forum_posts_per_page[$u_forum_id];
	}
// End : Forum Based Posts Per Page
I know this isn't the done thing, but can anyone advise on where I could place the above code? You can view an example of it in action (Oly showing 5 posts per page) 8-) and the incorrect pagnation by viewing this forum http://www.corradog60.com/viewforum.php?f=7 See topic with 32 pages? Well, click that topic and it's actually 63 pages :?
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
User avatar
RMcGirr83
Former Team Member
Posts: 22099
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Forum Based 'Posts Per Page'

Post by RMcGirr83 »

I just wrote this up https://github.com/RMcGirr83/forumpostsperpage

which will give you the ACP stuffs and one edit needed to viewtopic.php (README!!) as that seems to be the only file you really care about?
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then you can support me by buying a beer đŸș
User avatar
Volksdevil
Registered User
Posts: 2415
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil

Re: Forum Based 'Posts Per Page'

Post by Volksdevil »

Hi Rich, brill cheers for the help...

I assume that's what I already have working. Although through 100% hard edits rather than extension.
I currently have the ACP choice of posts per page in each forum.
I set a few of them to display 5 posts per page.
When viewing those forums, the pagination isn't correct (This is what I need help with)
When viewing the topic, the pagination is correct.

Example:
If you view this forum section here you will see a topic with an incorrect 32 pages, if you view that particular topic the pagination jumps up to 63 (Correct)

So it's the viewforum part that I'm struggling with. :)

It's great to see an extension underway! I will look at undoing my hard coding and trying your extension.
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
User avatar
RMcGirr83
Former Team Member
Posts: 22099
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Forum Based 'Posts Per Page'

Post by RMcGirr83 »

Why would it matter if the number of topics displayed when viewing the forum is greater than the number of posts allowed to display when viewing the topic?

The purpose, as you stated, to limit the number of posts to display was due to some posts having a lot of images in them. Those images don't show when viewing the forum, only when viewing the topic. The K.I.S.S. principle would seem to apply here.

EDIT

Find this in viewforum.php

Code: Select all

$phpbb_content_visibility = $phpbb_container->get('content.visibility');
AFTER ADD

Code: Select all

// extension forum posts per page
if (!empty($forum_data['forum_posts_per_page']))
{
    // overwrite config['posts_per_page']
    $config['posts_per_page'] = $forum_data['forum_posts_per_page'];
}
// end extension mod to file  
Last edited by RMcGirr83 on Wed Nov 26, 2014 7:46 pm, edited 2 times in total.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then you can support me by buying a beer đŸș
marcovo
Registered User
Posts: 239
Joined: Fri Nov 16, 2012 12:19 pm
Location: The Netherlands
Name: Marco

Re: Forum Based 'Posts Per Page'

Post by marcovo »

RMcGirr83, I guess you've misinterpreted Volksdevil's problem :P .
The problem is with an example-topic of 315 posts. The custom posts-per-page is set to 5, as such there should be 63 pages. This number of pages is correctly paginated on the viewtopic page (1 to 63), but on viewforum the pagination is incorrect, displaying 1 to 32 (e.g., using the default 10 posts per page). This is indeed inconsistent, although luckily all pages are still actually reachable through the pagination.
User avatar
RMcGirr83
Former Team Member
Posts: 22099
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Forum Based 'Posts Per Page'

Post by RMcGirr83 »

Post edited
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then you can support me by buying a beer đŸș
User avatar
Volksdevil
Registered User
Posts: 2415
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil

Re: Forum Based 'Posts Per Page'

Post by Volksdevil »

Marcovo, brill.
Rich, brill.

:D I just applied the viewforum.php tweak above and now the pagination is fixed/corrected.

Now to look at removing all my hard coded stuff to get this working, and try your ext. Should all be OK Rich?

When I applied the old MOD, I had to run the following query in phpmyadmin, should I remove that? Can I just drop/delete that table? Or better to run a query to do it?
ALTER TABLE phpbb_forums ADD COLUMN forum_posts_per_page SMALLINT(4) UNSIGNED NOT NULL DEFAULT '0';
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

Return to “Extension Requests”