[DISC] Improved pseudo sub-forums MOD 1.0.6

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Locked
da_badtz_one
Registered User
Posts: 376
Joined: Thu Jan 29, 2004 8:25 pm

Post by da_badtz_one »

@niekas:

Thanks ;) Forums now loading at 0.07 seconds now. And before that my server didn't have any load at all. 4 cpus and lots of ram only used about 3 percent of the cpu power.

Also:
doesn't seem to change anything to the speed


It actually doesn't seem to change the actual loading time. The loading time is the same but just a bit slower than usual. Though there isn't much of a problem. I hadn't noticed this was a problem until I noticed for the page statistics that the number is higher than usual.
Aldri
Registered User
Posts: 11
Joined: Sat Apr 23, 2005 10:24 pm

Post by Aldri »

ahhh thanks niekas for the index > parent > sub
:)

and for my board: i have about 15 to 20 other mods, and a large database (100 000 + posts), that may be why ;)
anyway, no user complained so..
niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

Aldri wrote: ahhh thanks niekas for the index > parent > sub
:)

and for my board: i have about 15 to 20 other mods, and a large database (100 000 + posts), that may be why ;)
anyway, no user complained so..


You welcome. BTW i have many many mods and also large forum (120K+ posts)

Index loads 0.06s on average

BTW for posting.php to display the parent of subforum

in posting.php

find

Code: Select all

make_jumpbox('viewforum.'.$phpEx);
Before add:

Code: Select all

if ($post_info[attached_forum_id]>0)
{
	$parent_lookup=$post_info[attached_forum_id];
}

In posting_body.tpl
find:

Code: Select all

		<!-- BEGIN switch_not_privmsg -->
before add:

Code: Select all

	  	  <!-- BEGIN switch_parent_link -->
	  	   -> <a class="nav" href="{PARENT_URL}">{PARENT_NAME}</a>
	  	  <!-- END switch_parent_link -->
esef
Registered User
Posts: 102
Joined: Fri Dec 17, 2004 7:40 pm
Contact:

Post by esef »

what is this?

Code: Select all

#
#-----[ SQL ]-------------------------------------------------
#
#       If your phpbb table prefix is different, then change it to
#      reflect the correct one.
#
     ALTER TABLE phpbb_forums ADD attached_forum_id MEDIUMINT(8) DEFAULT '-1' NOT NULL;
i know the mod won't work w/o it, but what does this mean?
User avatar
tahoebuff
Registered User
Posts: 1429
Joined: Tue Jul 20, 2004 12:33 am
Location: Nevada
Name: Michael
Contact:

Post by tahoebuff »

It means you have to run a database query. Hopefully you have access to phpMyAdmin. If you do...locate the database associated with your forum...click the SQL tab and cut/paste the following:

Code: Select all

ALTER TABLE phpbb_forums ADD attached_forum_id MEDIUMINT(8) DEFAULT '-1' NOT NULL;
Into the box and click go...(if your database tables start with something other than the default phpbb_, you will have to alter the above to reflect it)

Tahoebuff
User avatar
Merri
Registered User
Posts: 255
Joined: Mon Nov 25, 2002 1:08 pm
Location: Riihimäki, Finland
Contact:

Post by Merri »

niekas: if interested in removing one SQL call, take a look into $new_topic_data in index.php - I've rewrote my own index now. I also might have made the MOD to work with PostgreSQL and Oracle, I'm not sure though as I only tried to follow the logic already present in the SQL calls... this is what that part looks like:

Code: Select all

//
// Define appropriate SQL
//
switch(SQL_LAYER)
{
	case 'postgresql':
		$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, u.user_avatar, u.user_avatar_type, t.topic_id, t.topic_title, t.topic_moved_id
			FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . TOPICS_TABLE . " t
			WHERE p.post_id = f.forum_last_post_id
				AND u.user_id = p.poster_id
				AND t.topic_last_post_id = f.forum_last_post_id
				UNION (
					SELECT f.*, NULL, NULL, NULL, NULL
					FROM " . FORUMS_TABLE . " f
					WHERE NOT EXISTS (
						SELECT p.post_time
						FROM " . POSTS_TABLE . " p
						WHERE p.post_id = f.forum_last_post_id
					)
				)
				ORDER BY cat_id, forum_order";
		break;

	case 'oracle':
		$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, u.user_avatar, u.user_avatar_type, t.topic_id, t.topic_title, t.topic_moved_id
			FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . TOPICS_TABLE . " t
			WHERE p.post_id = f.forum_last_post_id(+)
				AND u.user_id = p.poster_id(+)
				AND t.topic_last_post_id = f.forum_last_post_id(+)
			ORDER BY f.cat_id, f.forum_order";
		break;

	default:
		$sql = "SELECT f.*, p.post_time, p.post_username,  u.username, u.user_id, u.user_avatar, u.user_avatar_type, t.topic_id, t.topic_title, t.topic_moved_id
			FROM ((( " . FORUMS_TABLE . " f
			LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
			LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
			LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = f.forum_last_post_id)
			GROUP BY f.forum_id ORDER BY f.cat_id, f.forum_order";
		break;
}
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
}
Oh, and to get the avatar... well, you know what is the extra code I use for that :)
niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

Merri,

What query does it remove? It looks pretty much the same except added avatar info.

:?:
User avatar
Merri
Registered User
Posts: 255
Joined: Mon Nov 25, 2002 1:08 pm
Location: Riihimäki, Finland
Contact:

Post by Merri »

The one filling up $new_topic_data:

Code: Select all

	//
	// Obtain a list of topic ids which contain
	// posts made since user last visited
	//
	if ( $userdata['session_logged_in'] )
	{
		$sql = "SELECT t.forum_id, t.topic_id, p.post_time 
			FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 
			WHERE p.post_id = t.topic_last_post_id 
				AND p.post_time > " . $userdata['user_lastvisit'] . " 
				AND t.topic_moved_id = 0"; 
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
		}

		$new_topic_data = array();
		while( $topic_data = $db->sql_fetchrow($result) )
		{
			$new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
		}
		$db->sql_freeresult($result);
	}
I don't have this in my index... though it probably doesn't even make much load to the SQL server as it most often returns nothing or just a few lines.
User avatar
Orphée
Registered User
Posts: 86
Joined: Sun Nov 10, 2002 9:31 pm
Location: France
Contact:

Post by Orphée »

The jumpbox doesn't work with this mod like :

Code: Select all

Forum 1
 |____ Forum 2 (subforum of forum 1)
 |____ Forum 3 (subforum of forum 1)
Someone can arrange it ?


( and why not in ACP > forums management make a structure like subforum )
thanks
niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

Merri wrote: The one filling up $new_topic_data:

Code: Select all

	//
	// Obtain a list of topic ids which contain
	// posts made since user last visited
	//
	if ( $userdata['session_logged_in'] )
	{
		$sql = "SELECT t.forum_id, t.topic_id, p.post_time 
			FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 
			WHERE p.post_id = t.topic_last_post_id 
				AND p.post_time > " . $userdata['user_lastvisit'] . " 
				AND t.topic_moved_id = 0"; 
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
		}

		$new_topic_data = array();
		while( $topic_data = $db->sql_fetchrow($result) )
		{
			$new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
		}
		$db->sql_freeresult($result);
	}
I don't have this in my index... though it probably doesn't even make much load to the SQL server as it most often returns nothing or just a few lines.


This query returns all topic ids that have new posts since last visit (multiple or zero rows per forum). Forum info query returns only the last post data (one row per forum). If you combine them it will get a lot more complicated and probably slower.

It probably would make more sense to combine currently separate queries for cats and forums.
Homeskillet
Registered User
Posts: 231
Joined: Thu Oct 07, 2004 5:00 am
Contact:

Post by Homeskillet »

HI...

Could someone please tell me how I can make this column smaller in width? Here is what it looks like now...

Image

I would like it to go back to about the same size it was before this mod and also to have the date on the bottom row instead of in the same row as the last posters name.

Thanks in advance for any help with this :D
...
User avatar
End of a Shadow
Registered User
Posts: 1557
Joined: Sun Apr 27, 2003 6:39 pm
Location: Washington
Name: J G
Contact:

Post by End of a Shadow »

Homeskillet wrote: HI...

Could someone please tell me how I can make this column smaller in width? Here is what it looks like now...

I would like it to go back to about the same size it was before this mod and also to have the date on the bottom row instead of in the same row as the last posters name.

Thanks in advance for any help with this :D

Code: Select all

$last_post = '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '">'.$forum_data[$j]['topic_title'].' <img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';

								$last_post .= '<br /> '; 
								$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
								$last_post .= ' '.$last_post_time;
Modify this to the way you wish it to appear on the board

But if you're pretty much bent sent to the way it was before then here's the original code.

Code: Select all

$last_post = $last_post_time . '<br />';

								$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
								
								$last_post .= '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';
User avatar
Merri
Registered User
Posts: 255
Joined: Mon Nov 25, 2002 1:08 pm
Location: Riihimäki, Finland
Contact:

Post by Merri »

Tip to niekas on that feature: make the post time a link to the post and have title attribute of the link to have the name of the topic. That is how I did it and doesn't take too much space (though I actually let the template decide how to handle it...)
Homeskillet
Registered User
Posts: 231
Joined: Thu Oct 07, 2004 5:00 am
Contact:

Post by Homeskillet »

End of a Shadow wrote:

Code: Select all

$last_post = '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '">'.$forum_data[$j]['topic_title'].' <img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';

								$last_post .= '<br /> '; 
								$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
								$last_post .= ' '.$last_post_time;
Modify this to the way you wish it to appear on the board

[/code]


Perfect...just needed to know where :D

So I added this

Code: Select all

$last_post .= '<br /> ';
BEFORE

Code: Select all

$last_post .= ' '.$last_post_time;
and it's exactly like I wanted.

THANK YOU.
...
soulcreeper
Registered User
Posts: 28
Joined: Wed Apr 06, 2005 8:08 am
Location: Breda, NL
Contact:

Post by soulcreeper »

is there a way that i can give the list of topics en header the same as the forumheader?

i.e. that this:


Image


will look like this:


Image


but without this happening, when viewing a topic:


Image
I'm just good at being the best ®
Locked

Return to “[2.0.x] MODs in Development”