Posts/topics per page /topic threshold by users choice?

This forum is now closed as part of retiring phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
User avatar
Carpe Diem
Registered User
Posts: 580
Joined: Tue Dec 10, 2002 11:19 pm

Posts/topics per page /topic threshold by users choice?

Post by Carpe Diem »

Hi.

I found this mod which allows users to choose their own posts and topics per page and also set the threshold for popular topics, in the profile page.

I tried to install but it does not work.
After installation I can not access viewforum's page.

Also, even though I mark the "do not override user style" option in the ACP board configuration page, it still does just that. If I choose another value of posts/topics per page in the profile and then click on submit and then go back to the profile page, it has already been over-written by the values set in the ACP configuration page.

Well at this point maybe that does not matter since the mod does not let you into the viewforum's page anyway..

Is anyone using this mod or something similar which WORKS? I would be very interested in such mod if it exists and works.. or maybe someone could take a look at this one and maybe find out what's wrong?!

Thx in advance!

Code: Select all

##################################################################################### 
## 
## Hack Title:   Post per page / Topics per page / Hot Threshold adjustable
##		 for every user in his profile
## Hack Version: 1.0
## Author:       Acid < acid_junky@web.de > 
## Description:  every user can adjust how much posts/topics should be displayed
##		 and hot threshold.
##
## Files To Edit: 5
##                language/lang_xxx/lang_main.php
##                includes/usercp_register.php
##                viewforum.php
##                viewtopic.php
##                templates/xxx/profile_add_body.tpl 
## 
##################################################################################### 
## 
## Installation/Author Notes: 
## First always make a back-up from the files that you're going to edit. 
## 
## This hack adds three new fields to your 'user' table. 
##################################################################################### 

>>SQL QUERY: (You may have to change your database prefix)

ALTER TABLE test_users ADD user_topics_per_page VARCHAR(5);
ALTER TABLE test_users ADD user_hot_threshold VARCHAR(5);
ALTER TABLE test_users ADD user_posts_per_page VARCHAR(5);
UPDATE test_users SET user_topics_per_page=50;
UPDATE test_users SET user_posts_per_page=15;
UPDATE test_users SET user_hot_threshold=15;

>>alternate you can use per_page_db_install.php to alter the database automatically
>>(just upload and run the file)

############################################################################################################################################

#################################################
# 
#-----[ OPEN ]------------------------------------------ 
#  
# language/lang_xxx/lang_main.php

>>FIND:
$lang['No_send_account_inactive'] = 'Sorry, but your password cannot be retrieved because your account is currently inactive. Please contact 

the forum administrator for more information';

>>ADD BELOW:
$lang['Topics_per_page'] = 'Topics Per Page';
$lang['Posts_per_page'] = 'Posts Per Page';
$lang['Hot_threshold'] = 'Posts for Popular Threshold';

############################################################################################################################################

#################################################
# 
#-----[ OPEN ]------------------------------------------ 
#  
# includes/usercp_register.php

>>FIND:
			$sql = "UPDATE " . USERS_TABLE . "
				SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_icq = '" 

. str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", 

$occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', 

user_sig = '" . str_replace("\'", "''", $signature) . "', user_sig_bbcode_uid = '$signature_bbcode_uid', user_viewemail = $viewemail, 

user_aim = '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = 

'" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, 

user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, 

user_popup_pm = $popuppm, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_lang = 

'" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_active = $user_active, user_actkey = '" . str_replace("\'", 

"''", $user_actkey) . "'" . $avatar_sql . "

>>FIND IN THIS LINE:
user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "'

>>ADD AFTER:
, user_posts_per_page = '" . str_replace("\'", "''", $user_posts_per_page) . "', user_topics_per_page = '" . str_replace("\'", "''", 

$user_topics_per_page) . "', user_hot_threshold = '" . str_replace("\'", "''", $user_hot_threshold) . "'

--------------------------------------------------------------------------------------------------

>>FIND:
			$sql = "INSERT INTO " . USERS_TABLE . "	(user_id, username, user_regdate, user_password, user_email, user_icq, 

user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, 

user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, 

user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
				VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", 

$new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", 

$website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", 

$interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail, '" . str_replace("\'", 

"''", str_replace(' ', '+', $aim)) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, 

$allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popuppm, $user_timezone, '" . str_replace("\'", "''", 

$user_dateformat) . "', '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1, ";

>>FIND IN THIS LINE:
user_dateformat

>>ADD AFTER:
, user_posts_per_page, user_topics_per_page, user_hot_threshold

>>FIND IN THIS LINE:
'" . str_replace("\'", "''", $user_dateformat) . "'

>>ADD AFTER:
, '" . str_replace("\'", "''", $user_posts_per_page) . "', '" . str_replace("\'", "''", $user_topics_per_page) . "', '" . str_replace("\'", 

"''", $user_hot_threshold) . "'

--------------------------------------------------------------------------------------------------

>>FIND:
		'ALWAYS_ALLOW_SMILIES_NO' => ( !$allowsmilies ) ? 'checked="checked"' : '',

>>ADD BELOW:
               	'POSTS_PER_PAGE' => ( $userdata['user_posts_per_page'] == '' ) ? $board_config['posts_per_page'] : 

$userdata['user_posts_per_page'],
               	'TOPICS_PER_PAGE' => ( $userdata['user_topics_per_page'] == '' ) ? $board_config['topics_per_page'] : 

$userdata['user_topics_per_page'],
               	'HOT_TOPIC' => ( $userdata['user_hot_threshold'] == '' ) ? $board_config['hot_threshold'] : $userdata['user_hot_threshold'],

--------------------------------------------------------------------------------------------------

>>FIND:
		'L_ALWAYS_ALLOW_HTML' => $lang['Always_html'],

>>ADD BELOW:
               	'L_HOT_THRESHOLD' => $lang['Hot_threshold'],
               	'L_POSTS_PER_PAGE' => $lang['Posts_per_page'],
               	'L_TOPICS_PER_PAGE' => $lang['Topics_per_page'],

############################################################################################################################################

#################################################
# 
#-----[ OPEN ]------------------------------------------ 
#  
# viewforum.php

>>FIND:
// Grab all the basic data (all topics except announcements)
// for this forum
//

>>ADD BELOW:
if ( $userdata['user_topics_per_page'] == '' )
{
        $per_page = $board_config['topics_per_page'];
}
else
{
        $per_page = $userdata['user_topics_per_page'];
}

--------------------------------------------------------------------------------------------------

>>FIND:
	LIMIT $start, ".$board_config['topics_per_page'];

>>REPLACE WITH:
	LIMIT $start, ".$per_page;

--------------------------------------------------------------------------------------------------

>>FIND:
		'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&topicdays=$topic_days", 

$topics_count, $board_config['topics_per_page'], $start),
		'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / 

$board_config['topics_per_page'] )), 

>>REPLACE WITH:
		'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&topicdays=$topic_days", 

$topics_count, $per_page, $start),
		'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / 

$per_page )), 

--------------------------------------------------------------------------------------------------

>>FIND:
				if($replies >= $board_config['hot_threshold'])

>>REPLACE WITH:
				if($replies >= $userdata['user_hot_threshold'])

--------------------------------------------------------------------------------------------------

>>FIND:
		if( ( $replies + 1 ) > $board_config['posts_per_page'] )
		{
			$total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] );
			$goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . 

$lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';

			$times = 1;
			for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
			{
				$goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . 

"&start=$j") . '">' . $times . '</a>';
				if( $times == 1 && $total_pages > 4 )
				{
					$goto_page .= ' ... ';
					$times = $total_pages - 3;
					$j += ( $total_pages - 4 ) * $board_config['posts_per_page'];

>>REPLACE WITH:
		if( ( $replies + 1 ) > $userdata['user_posts_per_page'] )
		{
			$total_pages = ceil( ( $replies + 1 ) / $userdata['user_posts_per_page'] );
			$goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . 

$lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';

			$times = 1;
			for($j = 0; $j < $replies + 1; $j += $userdata['user_posts_per_page'])
			{
				$goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . 

"&start=$j") . '">' . $times . '</a>';
				if( $times == 1 && $total_pages > 4 )
				{
					$goto_page .= ' ... ';
					$times = $total_pages - 3;
					$j += ( $total_pages - 4 ) * $userdata['user_posts_per_page'];

############################################################################################################################################

#################################################
# 
#-----[ OPEN ]------------------------------------------ 
#  
# viewtopic.php

>>FIND:
//
// Go ahead and pull all data for this topic
//

>>ADD BELOW:
if ( $userdata['user_posts_per_page'] == '' )
{
        $per_page = $board_config['posts_per_page'];
}
else
{
        $per_page = $userdata['user_posts_per_page'];
}

--------------------------------------------------------------------------------------------------

>>FIND:
	LIMIT $start, ".$board_config['posts_per_page'];

>>REPLACE WITH:
	LIMIT $start, ".$per_page;

--------------------------------------------------------------------------------------------------

>>FIND:
$pagination = ( $highlight_active ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . 

"=$topic_id&postdays=$post_days&postorder=$post_order&highlight=" . $HTTP_GET_VARS['highlight'], $total_replies, 

$board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . 

"=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);

>>REPLACE WITH:
$pagination = ( $highlight_active ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . 

"=$topic_id&postdays=$post_days&postorder=$post_order&highlight=" . $HTTP_GET_VARS['highlight'], $total_replies, 

$board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . 

"=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $per_page, $start);

--------------------------------------------------------------------------------------------------

>>FIND:
	'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['posts_per_page'] ) + 1 ), ceil( $total_replies / 

$board_config['posts_per_page'] )), 

>>REPLACE WITH:
	'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $per_page ) + 1 ), ceil( $total_replies / $per_page )), 

############################################################################################################################################

#################################################
# 
#-----[ OPEN ]------------------------------------------ 
#  
# templates/xxx/profile_add_body.tpl

>>FIND:
		<input type="radio" name="allowsmilies" value="0" {ALWAYS_ALLOW_SMILIES_NO} />
		<span class="gen">{L_NO}</span></td>
	</tr>

>>ADD BELOW:
	<tr>
		<td class="row1">{L_TOPICS_PER_PAGE}</td>
		<td class="row2"><input type="text" name="user_topics_per_page" size="3" maxlength="4" value="{TOPICS_PER_PAGE}" /></td>
	</tr>
	<tr>
		<td class="row1">{L_POSTS_PER_PAGE}</td>
		<td class="row2"><input type="text" name="user_posts_per_page" size="3" maxlength="4" value="{POSTS_PER_PAGE}" /></td>
	</tr>
	<tr>
		<td class="row1">{L_HOT_THRESHOLD}</td>
		<td class="row2"><input type="text" name="user_hot_threshold" size="3" maxlength="4" value="{HOT_TOPIC}" /></td>
	</tr>

############################################################################################################################################

#################################################
############################################################################################################################################

#################################################
############################################################################################################################################

#################################################
tbartold
Registered User
Posts: 138
Joined: Sat Mar 15, 2003 3:51 am
Contact:

Post by tbartold »

This is exactly what I have been looking for! Does anyone know if something like this mod is available from somewhere else? I was able to update this to work with phpBB 2.0.8 and EasyMod 11, but once I applied the patch for 2.0.9, it was no longer working. I have it working again on our board, so I'm thinking of submitting this for validation.

Here's my updated version of this MOD:

User Posts/Topics per page - Hot Threshold
Xayd
Registered User
Posts: 11
Joined: Sun Mar 28, 2004 10:50 am

Post by Xayd »

Just tested it on a 2.0.10 forum and it works great, thanks for updating it :).
tbartold
Registered User
Posts: 138
Joined: Sat Mar 15, 2003 3:51 am
Contact:

Post by tbartold »

Xayd wrote: Just tested it on a 2.0.10 forum and it works great, thanks for updating it :).


You're welcome. Sorry I didn't post that I figured out how to update it (I used the "add fields" mod as a pattern). I have it working on 2.0.10 also.
djwins
Registered User
Posts: 92
Joined: Thu May 01, 2003 7:06 pm

Post by djwins »

Very cool...I will check this out later.

Does anyone know if its possible to hard code a set number into a template?

If I wanted to create a template optimized for mobile devices, I'd likely want to limit the number of topics displayed specifically on that template, without having to have the user go into his profile and change the numbers.

Thanks.
User avatar
tarotamerica
Registered User
Posts: 230
Joined: Thu Feb 22, 2007 10:30 am
Contact:

Re: Posts/topics per page /topic threshold by users choice?

Post by tarotamerica »

This works great on my Forum, thank you! It was actually a special request from a member...

Three things:
  1. Be sure to reset the options to the identical defaults (e.g., Topics Per Page 20,
    Posts Per Page 15, and Posts for Popular Threshold 25) in ACP also, or Topics get truncated.
    [br]
  2. Change in profile_add_body.tpl

    Code: Select all

    <td class="row1"><span class="gen">{L_POSTS_PER_PAGE}:</span>
    
    to

    Code: Select all

    <td class="row1"><span class="gen">{L_POSTS_PER_PAGE}:</span><br /><span class="gensmall">{L_POSTS_PER_PAGE_EXPLAIN}</span></td>
    
  3. Change in lang_main.php

    Code: Select all

    $lang['Posts_per_page'] = 'Posts Per Page';
    $lang['Posts_per_page_explain'] = 'Setting this number less than the default 15 will cause Topics to be truncated.';
    
This may or may not happen in your Forum but it doesn't hurt, either.
Coincidences are God's way of remaining anonymous
—Albert Einstein
Post Reply

Return to “[2.0.x] MOD Requests”