[BETA] Flat Threaded Forum View

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.
Post Reply
bilofsky
Registered User
Posts: 74
Joined: Mon Feb 23, 2004 6:19 pm

[BETA] Flat Threaded Forum View

Post by bilofsky »

This is a MOD to display the same sort of information users get from a threaded forum page, within the phpBB flat organization. (It is not a MOD to make phpBB threaded.)

A lot of people like threaded views. (I know - that doesn't include the phpBB development team.)

For those who like threading as a way to navigate - this won't do it.

But a lot of users like to see who has posted to a topic, and how the discussion has evolved.

The solution presented by this MOD is to display, below each topic on the forum listing, the subject and author of each reply.

My community is used to a threaded board, and I think this will make phpBB more accessible to them. And I take their point about wanting to see this information.

The MOD can be seen in use on an active board. There are several styles. This is the style most like a threaded board (modeled after WWWBoard). This is the most subSilver-like style, and the one in the MOD listing.

A word of caution: I am a beginner when it comes to MODs, SQL, and php. So any help will be appreciated.

Code: Select all

##############################################################
## MOD Title: Flat Threaded Forum View
## MOD Author: bilofsky
## MOD Description: Shows threaded-like view in forum listing
## MOD Version: 0.0.3
##
## Installation Level: (Intermediate)
## Installation Time: 10 Minutes
## Files To Edit: 
##	viewforum.php
##	templates/subSilver/viewforum_body.tpl
##	templates/subSilver/overall_header.tpl
##	language/lang_english/lang_main.php
##
## Included Files: (n/a)
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes: This MOD augments the forum view by listing,
## under each topic subject, the subjects, authors and date/times
## of each reply in the topic. 
##	This MOD provides just one format with minimal changes
## to the subSilver style.  Other changes are possible, and one
## example - which more mimics the threaded look - is also given.
##    It is hoped that this will make phpBB more acceptable to
## those who are used to the look of threaded boards (like my users).
##############################################################
## MOD History:
##
##   2005-1-15 - Version 0.0.1
##      - first alpha version
##   2005-1-17 - Version 0.0.2
##      - Beta version - fix for multiple-page topics
##      - Display messages in post time order, not post number (only interesting for
##		converted databases)
##   2005-2-24 - Version 0.0.3
##      - Bug fix for users using sid (no cookies allowed)
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
## THIS MOD IS ALPHA, DON'T USE IT ON A PRODUCTION BOARD 
##############################################################

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

#
#-----[ FIND ]-----------------------------------
#
$lang['View_results'] = 'View Results';

#
#-----[ AFTER, ADD ]-----------------------------------
#

// Flat Thread MOD
lang['No_subject'] = '(reply)';

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

#
#-----[ FIND ]-----------------------------------
#
			$goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';

#
#-----[ REPLACE WITH ]-----------------------------------
#
			$goto_page = '<br> [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';


#
#-----[ FIND ]-----------------------------------
#
			'U_VIEW_TOPIC' => $view_topic_url)
		);

#
#-----[ AFTER, ADD ]-----------------------------------
#

// Begin Flat Tree MOD - Walt
		//
		// Retreive the username, user id and the number of posts
		//
		$sql = "SELECT p.post_id, p.poster_id, p.post_username, p.post_time, t.post_subject, u.username
			FROM " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " t, " . USERS_TABLE . " u
			WHERE topic_id = '$topic_id' 
				AND p.post_id = t.post_id
				AND u.user_id = p.poster_id
			ORDER BY p.post_time ASC";
// CHANGE TO 0.0.2 ^ - Walt

		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not obtain topic posters information', '', __LINE__, __FILE__, $sql);
		}
		$reply_info = $db->sql_fetchrowset($result);
		$db->sql_freeresult($result);

//FIXME: No list for moved posts.
		if (count($reply_info) > 1) {

			$template->assign_block_vars('topicrow.switch_replies', array() );

			for ( $j = 1; $j < count($reply_info); $j++ )
			{
				$author_reply = $guest_reply = $view_profile_url = '';
				$topic_reply = $reply_info[$j]['post_subject'];
// CHANGE TO 0.0.2 - Walt
				$k = '';
				if ($j >= $board_config['posts_per_page']) {
					$k = $board_config['posts_per_page'] * (int) ($j / $board_config['posts_per_page']);
					$k = "&start=$k";
					}
				if ($topic_reply == '') { $topic_reply = $lang['No_subject']; }
// CHANGE TO 0.0.3 - Walt
				$topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id$k") . "#" . $reply_info[$j]['post_id'];
				if ($reply_info[$j]['poster_id'] != -1)
				{
					$author_reply = $reply_info[$j]['username'];
					$view_profile_url = append_sid($phpbb_root_path . "profile." . $phpEx . "?mode=viewprofile&u=" . $reply_info[$j]['poster_id']);						
				}
				else	// If the user is a guest, don't include a link to the profile
				{
					$guest_reply = ($reply_info[$j]['post_username'] == '' ? $lang['Guest'] : 
										$reply_info[$j]['post_username']) ;
				}
				$reply_time = create_date($board_config['default_dateformat'], $reply_info[$j]['post_time'], $board_config['board_timezone']);

				$template->assign_block_vars('topicrow.switch_replies.replyrow', array(
					'REPLY_TOPIC' => $topic_reply,
					'U_REPLY_TOPIC' => $topic_url,
					'REPLY_AUTHOR' => $author_reply,
					'U_REPLY_AUTHOR' => $view_profile_url,
					'REPLY_GUEST' => $guest_reply,
					'REPLY_TIME' => $reply_time)
					);
				}
		}
// End Flat Tree MOD - Walt

#
#-----[ OPEN ]----------------------------------------
#
templates/subSilver/viewforum_body.tpl

#
#-----[ FIND ]-----------------------------------
#

	<!-- BEGIN topicrow -->
	<tr> 
	  <td class="row1" align="center" valign="middle" width="20"><img src="{topicrow.TOPIC_FOLDER_IMG}" width="19" height="18" alt="{topicrow.L_TOPIC_FOLDER_ALT}" title="{topicrow.L_TOPIC_FOLDER_ALT}" /></td>
	  <td class="row1" width="100%"><span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall"><br />
		{topicrow.GOTO_PAGE}</span></td>
	  <td class="row2" align="center" valign="middle"><span class="postdetails">{topicrow.REPLIES}</span></td>
	  <td class="row3" align="center" valign="middle"><span class="name">{topicrow.TOPIC_AUTHOR}</span></td>
	  <td class="row2" align="center" valign="middle"><span class="postdetails">{topicrow.VIEWS}</span></td>
	  <td class="row3Right" align="center" valign="middle" nowrap="nowrap"><span class="postdetails">{topicrow.LAST_POST_TIME}<br />{topicrow.LAST_POST_AUTHOR} {topicrow.LAST_POST_IMG}</span></td>
	</tr>
	<!-- END topicrow -->

#
#-----[ REPLACE WITH ]-----------------------------
#
	<!-- BEGIN topicrow -->
	<tr> 
	  <td class="row1" align="center" valign="top" width="20"><img src="{topicrow.TOPIC_FOLDER_IMG}" width="19" height="18" alt="{topicrow.L_TOPIC_FOLDER_ALT}" title="{topicrow.L_TOPIC_FOLDER_ALT}" /></td>
	  <td class="row1" width="100%" valign="top"><span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall">
		{topicrow.GOTO_PAGE}
	<!-- BEGIN switch_replies -->
		<table cellspacing="0" cellpadding="0" width="100%" class="ftsubj">
	<!-- BEGIN replyrow -->
		<tr><td width="10%">&nbsp;</td><td><a href="{topicrow.switch_replies.replyrow.U_REPLY_TOPIC}" class="ftsubj">{topicrow.switch_replies.replyrow.REPLY_TOPIC}</a>:  <a href="{topicrow.switch_replies.replyrow.U_REPLY_AUTHOR}" class="ftauth"><b>{topicrow.switch_replies.replyrow.REPLY_AUTHOR}</b></a><span class="ftauth">{topicrow.switch_replies.replyrow.REPLY_GUEST}</span></td></tr>
	<!-- END replyrow -->
		</table>
	<!-- END switch_replies -->
		</span></td>
	  <td class="row2" align="center" valign="middle"><span class="postdetails">{topicrow.REPLIES}</span></td>
	  <td class="row3" align="center" valign="top"><span class="name">{topicrow.TOPIC_AUTHOR}</span></td>
	  <td class="row2" align="center" valign="top"><span class="postdetails">{topicrow.VIEWS}</span></td>
	  <td class="row3Right" align="center" valign="top" nowrap="nowrap"><span class="postdetails">{topicrow.LAST_POST_TIME}<br />{topicrow.LAST_POST_AUTHOR} {topicrow.LAST_POST_IMG}</span></td>
	</tr>
	<!-- END topicrow -->

#
#-----[ OPEN ]----------------------------------------
#
templates/subSilver/overall_header.tpl

#
#-----[ FIND ]-----------------------------------
#

.helpline { background-color: {T_TR_COLOR2}; border-style: none; }

#
#-----[ AFTER, ADD ]-----------------------------------
#

/* Flat Thread MOD: Fonts used for subject and author in reply listing in forum page */
.ftsubj,.ftauth { font-size : {T_FONTSIZE2}px; color : {T_BODY_TEXT}; text-decoration: none; }
a.ftsubj,a.ftauth { text-decoration: none; }

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM  
This is the alternative viewforum_body.tpl code for the threaded-board-like display:

Code: Select all

	<!-- BEGIN topicrow -->
	<tr> 
	  <td width="100%" valign="top"><img src="{topicrow.TOPIC_FOLDER_IMG}" width="19" height="18" align="absmiddle" alt="{topicrow.L_TOPIC_FOLDER_ALT}" title="{topicrow.L_TOPIC_FOLDER_ALT}" />
	  <span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a></span>
		 - <span class="name">{topicrow.TOPIC_AUTHOR}</span>
		<span class="postdetails">&nbsp;&nbsp;<i>{topicrow.FIRST_POST_TIME}</i> ({topicrow.VIEWS} views)</span>
		<span class="gensmall">{topicrow.GOTO_PAGE}</span>
	<!-- BEGIN switch_replies -->
		<ul class="ftsubj">
	<!-- BEGIN replyrow -->
		<li><a href="{topicrow.switch_replies.replyrow.U_REPLY_TOPIC}" class="ftsubj">{topicrow.switch_replies.replyrow.REPLY_TOPIC}</a> - <a href="{topicrow.switch_replies.replyrow.U_REPLY_AUTHOR}" class="ftauth"><b>{topicrow.switch_replies.replyrow.REPLY_AUTHOR}</b></a><span class="ftauth">{topicrow.switch_replies.replyrow.REPLY_GUEST}</span>&nbsp;&nbsp;<span class="postdetails"><i>{topicrow.switch_replies.replyrow.REPLY_TIME}</i></span></li>
	<!-- END replyrow -->
		</ul>
	<!-- END switch_replies -->
		</td>
	</tr>
	<!-- END topicrow -->
Last edited by bilofsky on Fri Feb 25, 2005 5:59 am, edited 5 times in total.
danb00
Registered User
Posts: 1025
Joined: Sun Dec 15, 2002 9:41 pm
Location: Inside Mod:Extreme PHPBB
Contact:

Post by danb00 »

nice mod :) would be nice if sub forums had something like this
phpBBModded.com - Modding phpBB
bilofsky
Registered User
Posts: 74
Joined: Mon Feb 23, 2004 6:19 pm

Post by bilofsky »

Edited 2/12/05 - now in Beta. This MOD is now in use on my active board and seems to work OK.

I would appreciate a report from anyone who is using this (successfully or not).
tanner_S.
Registered User
Posts: 446
Joined: Sun Oct 10, 2004 9:04 pm

Post by tanner_S. »

Does this include a on/off switch in the users's profile? Or is it just default?

-Tanner
bilofsky
Registered User
Posts: 74
Joined: Mon Feb 23, 2004 6:19 pm

Post by bilofsky »

That is up to the admin and the user.

The MOD just changes the way the index page is presented - in other words, it provides more alternatives that can be used in the styles.

The MOD is presented as a change to subSilver. But the recommended way to install it is to create one or more new styles. Then the admin decides which style to use as the default, and whether to let the users choose a different style. You can run this style and subSilver (or other flat styles) on the same board.
tanner_S.
Registered User
Posts: 446
Joined: Sun Oct 10, 2004 9:04 pm

Post by tanner_S. »

Could it be turn on/offable in the users profile?

I noticed that if they put a subject on the subject line when they reply to a post it will say "Re: Whatever" than "(Reply)".

Any way to make "(reply): Username" the same size as the topic title?

BTW this:

Code: Select all

// Flat Thread MOD 
lang['No_subject'] = '(reply)'; 
Should be:

Code: Select all

// Flat Thread MOD 
$lang['No_subject'] = '(reply)'; 
-Tanner
bilofsky
Registered User
Posts: 74
Joined: Mon Feb 23, 2004 6:19 pm

Post by bilofsky »

tanner_S. wrote: Could it be turn on/offable in the users profile?

Yes. Both can exist on the same board and the user can switch between them.

Install the MOD by creating a second style with the specified template changes, rather than by modifying subSilver. Then the user can switch between the new "flat thread" style and the default subSilver style in his profile.

To see this, click here to view my board in the subSilver style. Then see it in the "flat thread" styles by clicking the example links in the original post.
I noticed that if they put a subject on the subject line when they reply to a post it will say "Re: Whatever" than "(Reply)".

(Reply) is just for a blank subject.
Any way to make "(reply): Username" the same size as the topic title?

Yes, you can change the definitions of the styles ftsubj and ftauth in overall_header.tpl. But you may find that a larger font will make the index body display too wide.
BTW this ...


Fixed. Thanks.

- Walt Bilofsky
bilofsky
Registered User
Posts: 74
Joined: Mon Feb 23, 2004 6:19 pm

Post by bilofsky »

Another way for users to turn the thread-like index page view off and on - you could provide a link for them to change styles in the header or on some of the pages.

See the change style MOD for a way to let users change styles by clicking.

Then give them two similar styles, with and without the list of replies, and they can switch back and forth on the fly.
CPark
Registered User
Posts: 8
Joined: Mon Dec 06, 2004 10:57 pm

Mulitple indents

Post by CPark »

This looks really really good. I'm in exactly the same place, where I'm converting from WWWBoard to phpBB. Is there a way for it to indent multiple times? With WWWBoard, a reply to a reply is indented twice, as are third- and fourth-level replies. Any way to make that happen?
bilofsky
Registered User
Posts: 74
Joined: Mon Feb 23, 2004 6:19 pm

Conversion from threaded forum

Post by bilofsky »

I see I wound up writing a long answer, which you might find useful. But first I should answer your question. :) No, my MOD doesn't do that.

The purpose of this MOD is to get part of the benefit of a threaded forum, but within the flat structure of phpBB. I'd like to think it gets 50% of the benefit with 2% of the effort.

WWWBoard is a threaded forum. phpBB is a flat forum. There is an essential difference between the way they structure topics. In fact the nature of the discussion differs. In a threaded forum, each message is a reply to one other message. In phpBB and other flat forums it is an ongoing group discussion with each person "speaking" in turn.

That poses a sticky conversion problem, but once you have converted, you have flat threads. Conceivably you could display the old, converted threads as a tree, but the new ones are all going to be flat. So I didn't even think about it.

If the threaded structure is essential to your community, you may want to consider alternative boards. You could look at Moby Threads, which is a threaded offshoot of phpBB. We chose not to go that route because of the larger support community for mainstream phpBB. YMMV. There are other alternatives.

OK, more than you wanted to know. Please pick the desired information out of the rubble. :wink:
CPark
Registered User
Posts: 8
Joined: Mon Dec 06, 2004 10:57 pm

Thanks.

Post by CPark »

Thanks for explaining all of that. Good distinctions, and I appreciate your writing it up.
bilofsky
Registered User
Posts: 74
Joined: Mon Feb 23, 2004 6:19 pm

Version 0.0.3 Posted

Post by bilofsky »

The code in the original post has been changed to reflect version 3.

The only changes from version 1 are in viewforum.php between

// Begin Flat Tree MOD - Walt

and

// End Flat Tree MOD - Walt

This fixes a couple of bugs - topics spanning more than one page, and users using session ids (i.e., blocking cookies).
somethingsgottagive
Registered User
Posts: 7
Joined: Thu Jan 13, 2005 10:12 pm

hi thanks for the mod....

Post by somethingsgottagive »

hi and thanks for the great mod...

is there any way to display the replies on the viewtopic page instead of on the viewforum page.

and ideally under the first post before the replies.

thanks in advance.
bilofsky
Registered User
Posts: 74
Joined: Mon Feb 23, 2004 6:19 pm

Post by bilofsky »

I'm sure there is, but since I don't need that and it's a fair amount of work, I'll leave that to someone else.

If you can code a little php, you could try taking the code from viewforum.php and see if it can be fit into viewtopic.php with minor modifications. It'll require changing the templates too, of course.
Post Reply

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