Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: codenaught on July 06, 2006, 01:08:41 PM

Title: Post Limit Options
Post by: codenaught on July 06, 2006, 01:08:41 PM
Link to Mod (http://mods.simplemachines.org/index.php?mod=380)

This mod adds a theme setting that every user can change so they can view their own desired number of topics per page and posts per page as oppose to using the default limits set by the administrator.

Users can find these two settings (Topics per page and Posts per page) in their Profile / Look and Layout Settings  where they will see a dropdown  where they can pick the following options:

Title: Re: Post Limit Options
Post by: kezayah on July 06, 2006, 03:11:05 PM
 :'(
Can you put your archive in .zip please ???  :D
Title: Re: Post Limit Options
Post by: PrizeLive.com on July 06, 2006, 03:12:34 PM
great, thanks!!

what's it matter if its not in .zip or not?
Title: Re: Post Limit Options
Post by: kezayah on July 06, 2006, 03:16:31 PM
I try but it doesn't work for me ...  :'(
Title: Re: Post Limit Options
Post by: PrizeLive.com on July 06, 2006, 03:26:48 PM
Quote from: kezayah on July 06, 2006, 03:16:31 PM
I try but it doesn't work for me ...  :'(

hmmm i wonder why.. it installed fine for me..
Title: Re: Post Limit Options
Post by: kezayah on July 06, 2006, 03:35:12 PM
It's because Winrar doesn't open the file *tar.gz ... i don't know why ...  ::)
You can put a link with this archive *.zip ...
Sorry for my english, I'm french ...
Title: Re: Post Limit Options
Post by: MartinB on July 07, 2006, 03:49:42 AM
max. Topics per Page do not work.
The error is however fast repaired.
Replace in install.xml
This:
<file name="$sourcedir/MessageIndex.php">>
<operation>
<search position="after"><![CDATA[
// View all the topics, or just a few?
$maxindex = isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) ? $board_info['num_topics'] : $modSettings['defaultMaxTopics'];
]]></search>
<add><![CDATA[
// If the user has inputted 0, it is the default and should be ignored.
if(!empty($options['num_topics_page']))
$modSettings['defaultMaxTopics'] = $options['num_topics_page'];
]]></add>
</operation>

with this:
<file name="$sourcedir/MessageIndex.php">>
<operation>
<search position="before"><![CDATA[
// View all the topics, or just a few?
$maxindex = isset($_REQUEST['all']) && !empty($modSettings['enableAllMessages']) ? $board_info['num_topics'] : $modSettings['defaultMaxTopics'];
]]></search>
<add><![CDATA[
// If the user has inputted 0, it is the default and should be ignored.
if(!empty($options['num_topics_page']))
$modSettings['defaultMaxTopics'] = $options['num_topics_page'];
]]></add>
</operation>


If the installations point is not after but before it, it goes also with the maximum announcement of the topics
Sorry my English not Perfekt, but I hope it am understandably which I mean.
Title: Re: Post Limit Options
Post by: littleone on July 07, 2006, 06:40:41 PM
I havent noticed any problems with it.  Its a great mod.  Thanks ;)
Title: Re: Post Limit Options
Post by: PrizeLive.com on July 07, 2006, 08:14:21 PM
How can I add "15" as a choice for "The number of topics to show per page in a board:"
Title: Re: Post Limit Options
Post by: codenaught on July 08, 2006, 08:15:19 PM
MartinB, I don't see how that would make it work as oppose to how it currently is. The search after means that it searches for that text after the text has been added. So then if the $modSettings['defaultMaxTopics'] gets updated after the $maxindex variable it would have no effect, as the constructPageIndex function passes the value of $maxindex and not $modSettings['defaultMaxTopics'].

SurfExcelerator.com, you can add 15 by doing the following:

Edit Themes/default/Profile.template.php:

Find:

<option value="10"', !empty
($context['member']['options']['num_topics_page']) && $context['member']['options']['num_topics_page'] == 10 ? ' selected="selected"' : '', '>10</option>


After add:

<option value="15"', !empty
($context['member']['options']['num_topics_page']) && $context['member']['options']['num_topics_page'] == 15 ? ' selected="selected"' : '', '>15</option>


And then:

Edit: Themes/default/Settings.template.php

and find:

array(
'id' => 'num_topics_page',
'label' => $txt['admin_num_topics'],
'options' => array(
'default' => '0',
10 => '10',
25 => '25',
50 => '50',
75 => '75',
100 => '100',
),
'default' => true,
),


And change it to this:

array(
'id' => 'num_topics_page',
'label' => $txt['admin_num_topics'],
'options' => array(
'default' => '0',
10 => '10',
                                15 => '15',
25 => '25',
50 => '50',
75 => '75',
100 => '100',
),
'default' => true,
),
Title: Re: Post Limit Options
Post by: PrizeLive.com on July 13, 2006, 03:33:44 PM
Thanks.... changes were made and it works.....  :D
Title: Re: Post Limit Options
Post by: ltdeta on July 14, 2006, 07:42:37 AM
any plans for SMf Version 1.0.7 ?
Title: Re: Post Limit Options
Post by: codenaught on August 31, 2006, 12:01:52 AM
This mod is now compatable with the SMF 1.0 branch. I realized VERY few changes were needed to get this mod to work for 1.0. :) To use the mod for SMF 1.0x, download and install the "Post_Limit_SMF1.0.zip" package.

Quote from: ltdeta on July 14, 2006, 07:42:37 AM
any plans for SMf Version 1.0.7 ?
While this mod was tested on 1.0.8, I am almost sure it will work fine on 1.0.7. :) Though this post was made well before 1.0.8 was released, so you quite possibly may have upgraded to 1.0.8 already. ;)
Title: Re: Post Limit Options
Post by: scottws on September 13, 2006, 12:06:50 AM
SMF 1.1 RC3:

"The package you are trying to download or install is either corrupt or not compatible with this version of SMF."

Tried both the .tar.gz and .zip with the same results.
Title: Re: Post Limit Options
Post by: scottws on September 13, 2006, 10:12:26 PM
I just tried to open the .tar.gz file with WinRAR... it is corrupt.  I also can't install it on the forum, as my previous post mentioned.
Title: Re: Post Limit Options
Post by: codenaught on September 14, 2006, 03:50:20 PM
I just downloaded it, and it worked fine. Can you try downloading it again? Also are other mods on the mod site corrupt for you as well?
Title: Re: Post Limit Options
Post by: scottws on September 15, 2006, 09:56:54 AM
Odd. Based on your suggestion, I tried it again from another computer and it worked fine.  Strange.  I'm not sure why it was getting corrupted on my main computer.
Title: Re: Post Limit Options
Post by: BigGunn on November 10, 2006, 05:05:50 AM
how would I go about applying this to other themes than the default one? I have several themes installed on my boards.
Title: Re: Post Limit Options
Post by: inthe80s on January 17, 2007, 05:00:51 PM
I just started using this mod before I upgraded to 1.1.1

any plans on an update?
Title: Re: Post Limit Options
Post by: codenaught on January 17, 2007, 05:03:19 PM
The mod works fine for me in 1.1.1. Are you having problems? If so what are they?
Title: Re: Post Limit Options
Post by: inthe80s on January 17, 2007, 08:06:49 PM
Quote from: akabugeyes on January 17, 2007, 05:03:19 PM
The mod works fine for me in 1.1.1. Are you having problems? If so what are they?

I'm having problems installing through the package manager, first it won't give me a download link when I browse for it, then if I upload it I get the following:

The package you are trying to download or install is either corrupt or not compatible with this version of SMF.

I'm assuming it's a version issue thing, but I didn't dig further than that.
Title: Re: Post Limit Options
Post by: codenaught on January 17, 2007, 08:14:59 PM
Are you using the one designed for SMF 1.1x? The package is called "PostLimitOptions.tar.gz." The one that is for SMF 1.0 is called "Post_Limit_SMF1.0.zip."
Title: Re: Post Limit Options
Post by: inthe80s on January 17, 2007, 08:40:39 PM
Quote from: akabugeyes on January 17, 2007, 08:14:59 PM
Are you using the one designed for SMF 1.1x? The package is called "PostLimitOptions.tar.gz." The one that is for SMF 1.0 is called "Post_Limit_SMF1.0.zip."

That was the problem.

For some reason, when you use the browse package function, the link to the old version is the only one that shows up.  There's also nothing in the description about the version differences. 

Thanks for solving that for me.  Works like a champ now.
Title: Re: Post Limit Options
Post by: Kardinal on August 03, 2007, 04:16:26 PM
Has anyone gotten this working with 1.1.3? 

The error we're getting is:
QuoteThe package you are trying to download or install is either corrupt or not compatible with this version of SMF.
Title: Re: Post Limit Options
Post by: codenaught on August 03, 2007, 04:22:11 PM
I tried installing this yesterday and it worked fine for me. Can you try downloading it again. Preferably with a different browser? IE can sometimes corrupt downloads, so if you are using that, that could be the cause.

Edit: Also make sure you are downloading "PostLimitOptions.tar.gz," the other package is for SMF 1.0.
Title: Re: Post Limit Options
Post by: redactor007 on August 03, 2007, 09:11:20 PM
Quote from: akabugeyes on August 03, 2007, 04:22:11 PM
I tried installing this yesterday and it worked fine for me. Can you try downloading it again. Preferably with a different browser? IE can sometimes corrupt downloads, so if you are using that, that could be the cause.

Edit: Also make sure you are downloading "PostLimitOptions.tar.gz," the other package is for SMF 1.0.

I'm with Kardinal, I'm actually the one hosting the site and yes, I had downloaded the one for SMF 1.0.  I tried using the other one and it worked like a champ except for it only installed the options into the default theme.  What do I have to do to get it into the other themes?

Thanks,

Oh and btw, I'm a programming n00b so detailed instructions would be VERY appreciated

-Red
Title: Re: Post Limit Options
Post by: karlbenson on August 03, 2007, 09:22:21 PM
Manual Installation of Mods
http://docs.simplemachines.org/index.php?topic=402
Title: Re: Post Limit Options
Post by: codenaught on August 25, 2007, 04:26:35 PM
All, I have released an update to this mod.

The update has only one small change in it but it's a fairly critical fix. It was possible with the old version of the mod for a user to set it so they could view more than 100 topics and posts per page. This could cause problems with load times if someone views a topic with 100s of replies or a board with 100s of topics.

To update, just download package "PostLimitOptions1.0.1_SMF1.1.zip" and upload it to your package manager. You do not have to uninstall the original mod. I have included a upgrade file in it so it will just apply the small fix needed for the upgrade.

Two additional things:

I would like to use this moment to officially announce that I will no longer be patching the SMF 1.0 line of this mod. I really don't think many people are still using 1.0, and even fewer that are also using the mod as well. However I will point out how to manually patch this if you do use this mod and are currently using SMF 1.0. This also applies to those who have trouble getting the mod updated when using the mod package and are running SMF 1.1.

Open Sources/Profile.php:

Find:

// These are the theme changes...
$themeSetArray = array();


Add after:

// Don't allow anything over the maxiumum allowed posts or topics per page,
if (isset($_POST['default_options']['num_posts_page']) && $_POST['default_options']['num_posts_page'] > 100)
$_POST['default_options']['num_posts_page'] = $modSettings['defaultMaxMessages'];
if (isset($_POST['default_options']['num_posts_page']) && $_POST['default_options']['num_topics_page'] > 100)
$_POST['default_options']['num_topics_page'] = $modSettings['defaultMaxTopics'];


The second thing is, now that SMF 2.0 Beta 1 has been released to Charter Members, I think it is okay to say that the same functionality that is present in this mod is now a default feature of SMF 2.0. So this mod will not be updated for SMF 2.0 as it doesn't need to be. :)
Title: Re: Post Limit Options
Post by: Chipicao on December 06, 2007, 04:42:33 PM
When I go to index.php?action=unread , the pages are always calculated using the old default posts/page setting (20). I think I should just add this code


// If the user has inputted 0, it is the default and should be ignored.
if(!empty($options['num_posts_page']))
$modSettings['defaultMaxMessages'] = $options['num_posts_page'];


The problem is I can't find the php where these pages are calculated. Can someone help please?
Title: Re: Post Limit Options
Post by: mattstan on February 07, 2008, 04:16:57 PM
QuoteAn Error Has Occurred!

The package you tried to upload either is not a valid package or has become corrupted.

I've confirmed that I downloaded the correct version (I'm running SMF 1.1.4, and this is PostLimitOptions1.0.1_SMF1.1.zip).  If I try opening the Zip file locally, Filzip says, "Warning - Error in zip structure!"  I've tried downloading from multiple computers, as suggested above.  Linux unzip also spits out a lot of errors, and the resulting unpacked files are recognizably XML but very garbled.
Title: Re: Post Limit Options
Post by: Eliana Tamerin on February 16, 2008, 10:57:14 AM
I have received the same error. A shame, I had wanted this mod. Anybody have a copy on their computer they'd be willing to upload to a post?
Title: Re: Post Limit Options
Post by: codenaught on February 18, 2008, 03:05:12 PM
Seems the package has become corrupted. I will try to upload a working package as soon as I can. It doesn't look like I have the package on the computer I am using right now. :(
Title: Re: Post Limit Options
Post by: scottws on March 04, 2008, 08:00:34 PM
Here's a copy of 1.0.1. (http://scottws.zapto.org/files/PostLimitOptions1.0.1_SMF1.1.zip)
Title: Re: Post Limit Options
Post by: codenaught on May 01, 2008, 06:46:08 PM
Thanks scottws, appreciated. :)

Working package has been uploaded to the mod page. Also would like to let people know that this mod will work with the just released SMF 1.1.5.
Title: Re: Post Limit Options
Post by: raklet on May 01, 2008, 09:27:12 PM
Great module!  My forum users love it.  I found an oversight in the code.  It does not take into account user preferences for "Show new replies to your posts" which is generated out of Recent.php.  It uses the forum default settings for number of topics to display rather than the user chosen number of topics.  I added the following code to install.xml to fix this issue.  It works great.

<file name="$sourcedir/Recent.php">
<operation>
<search position="replace"><![CDATA[
function UnreadTopics()
{
global $board, $txt, $scripturl, $db_prefix, $sourcedir;
global $ID_MEMBER, $user_info, $context, $settings, $modSettings, $func;
]]></search>
<add><![CDATA[
function UnreadTopics()
{
global $board, $txt, $scripturl, $db_prefix, $sourcedir;
global $ID_MEMBER, $user_info, $context, $settings, $modSettings, $func, $options;

// Allow user topic and post settings to override defaults
if(!empty($options['num_topics_page']))
$modSettings['defaultMaxTopics'] = $options['num_topics_page'];
if(!empty($options['num_posts_page']))
$modSettings['defaultMaxMessages'] = $options['num_posts_page'];

]]></add>
</operation>
</file>



Just curious why MessageIndex and Recent.php have to be modified.  Why can't all of this be consolidated into Load.php and then it will work anywhere that $modSettings['defaultMax...'] is called?  I tried doing it but it didn't seem to pick up the user settings.  I still don't thoroughly understand the program and maybe you could shed some light on its inner workings.

Thanks,

Raklet
Title: Re: Post Limit Options
Post by: codenaught on May 01, 2008, 10:45:13 PM
Well I could just completely overwrite the variable. I think at the time what I was thinking was that there could be circumstances where a script makes use of these values in some kind of way that would want to get the overall forum default values rather than what the user may have picked. If I decided to overwrite the variable on every page then it would make it hard for a script to use the actual forum default if it wants to ignore the user preference for some reason.

That being said I suppose the Unread Posts page could respect the setting. I'll probably go ahead and include that in a future update to the mod. :)
Title: Re: Post Limit Options
Post by: raklet on May 01, 2008, 11:01:30 PM
Quote from: akabugeyes on May 01, 2008, 10:45:13 PM
Well I could just completely overwrite the variable. I think at the time what I was thinking was that there could be circumstances where a script makes use of these values in some kind of way that would want to get the overall forum default values rather than what the user may have picked. If I decided to overwrite the variable on every page then it would make it hard for a script to use the actual forum default if it wants to ignore the user preference for some reason.

That makes good sense.  I can see the reason in that.  Thanks for the clarification, and thanks for the quick response!
Title: Re: Post Limit Options
Post by: forum4ttt on September 17, 2008, 09:02:37 PM
I installed PostLimitOptions into 1.1.6 and the Package Manager confirmed a successful install.  However, I do not have a dropdown in Profile/Look and Layout from which to choose a setting.

Does the mod work in 1.1.6?  I assumed it did as there was a manual installation file for download for 1.1.6.
Title: Re: Post Limit Options
Post by: forum4ttt on September 20, 2008, 10:35:14 AM
Quote from: forum4ttt on September 17, 2008, 09:02:37 PM
I installed PostLimitOptions into 1.1.6 and the Package Manager confirmed a successful install.  However, I do not have a dropdown in Profile/Look and Layout from which to choose a setting.

Does the mod work in 1.1.6?  I assumed it did as there was a manual installation file for download for 1.1.6.
could someone please confirm running this mod in 1.1.6 successfully
thanks
Title: Re: Post Limit Options
Post by: raklet on December 06, 2008, 06:55:16 PM
I have it running in 1.1.6.  I installed it sometime ago and it survived through the upgrades.  Look for the options under Profile / Look and Layout:

The number of topics to show per page in a board:
The number of posts to show per page in a topic: