[ALPHA] Attached forums or pseudo sub-forums mod 1.0.0

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
User avatar
harishankar
Registered User
Posts: 99
Joined: Tue Oct 26, 2004 3:37 pm
Contact:

[ALPHA] Attached forums or pseudo sub-forums mod 1.0.0

Post by harishankar » Thu Dec 09, 2004 12:00 pm

This is a mod which adds 'pseudo' subforum or attached forums. This will remove the forums which are "attached" to another forum from the index and display it under the forum to which it is attached.

It has been tested in a local environment so far and it works as far as I know. This is meant to be a simple MOD so that people who don't want a 'FULL' sub-forum feature can use this instead.

In short it emulates the sub-forums capability. Test in a local or testing environment before adding this MOD to a live environment.

No files included. Only full MOD.

Code: Select all

##############################################################
## MOD Title: Attached forums or pseudo sub-forums MOD
## MOD Author: harishankar < v_harishankar@yahoo.co.in > (Harishankar) http://literaryforums.org
## MOD Description: This mod allows you to "attach" specific forums to another so that they are not displayed on the main index page but inside another forum. This emulates the sub-forums features but does not really create true sub-forum functionality.
##
## MOD Version: 1.0.1 (alpha)
##
## Installation Level: (Easy)
## Installation Time: 10 Minutes
## Files To Edit: 	admin/admin_forums.php
##						templates/subSilver/admin/forum_edit_body.tpl
##						index.php
##						templates/subSilver/index_body.tpl
##						viewforum.php
##						templates/subSilver/viewforum_body.tpl
##						language/lang_english/lang_main.php
##						language/lang_english/lang_admin.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:
##
##		Test this MOD in a testing/isolated enviroment. Although
##		no obvious bugs have been found yet, this MOD *should*
##		work in a live environment as well. I am well aware of
##		certain features missing. That is due to two reasons:
##
##		1. I don't want to make this MOD too difficult and
##		   cumbersome to install which I wanted to avoid.
##		2. To add certain features like "last post" on index
##		   to integrate with this MOD a lot of functionality
##		   will have to be duplicated.
##
##############################################################
## MOD History:
##
##   2004-12-11 - Version 1.0.1
##      - Alpha release :)
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ 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;

#
#-----[ OPEN ]------------------------------------------------
#
	admin/admin_forums.php

#
#-----[ FIND ]------------------------------------------------
#
	$forumstatus = $row['forum_status'];
	
#
#-----[ AFTER, ADD ]------------------------------------------
#
	// Added by Harishankar's Attached Forums MOD
	$forum_attached_id = $row['attached_forum_id'];
	// End add

#
#-----[ FIND ]------------------------------------------------
#
	
	'S_PRUNE_ENABLED' => $prune_enabled,

#
#-----[ AFTER, ADD ]------------------------------------------
#
	// Added by Harishankar's Attached Forums MOD
	'S_ATTACHED_FORUM_ID' => $forum_attached_id,
	// End add
		
#
#-----[ FIND ]------------------------------------------------
#
	'L_CATEGORY' => $lang['Category'], 

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

	// Added by Harishankar's Attached Forums MOD
	'L_ATTACHED_FORUM' => $lang['Attached_Field_Title'] ,
	'L_ATTACHED_DESC' => $lang['Attached_Description'],
	// End add

#
#-----[ FIND ]------------------------------------------------
#
	$sql = "INSERT INTO " . FORUMS_TABLE .

#
#-----[ IN-LINE FIND ]----------------------------------------
#
	cat_id,

#
#-----[ IN-LINE AFTER, ADD ]-----------------------------------
#		
	attached_forum_id, 
	
#
#-----[ IN-LINE FIND ]-----------------------------------------
#
	intval($HTTP_POST_VARS[POST_CAT_URL]) .

#
#-----[ IN-LINE AFTER, ADD ]-----------------------------------
#
	", " . intval($HTTP_POST_VARS['attached_forum_id']) . 

#
#-----[ FIND ]------------------------------------------------
#
	$sql = "UPDATE " . FORUMS_TABLE . "
		SET forum_name = '" .

#
#-----[ IN-LINE FIND ]----------------------------------------
#
	cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) .
	
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
	", attached_forum_id = " . intval($HTTP_POST_VARS['attached_forum_id']) .

#
#-----[ OPEN ]------------------------------------------------
#
	templates/subSilver/admin/forum_edit_body.tpl

#-----[ FIND ]------------------------------------------------
	
	<tr> 
	  <td class="row1">{L_CATEGORY}</td>
	  <td class="row2"><select name="c">{S_CAT_LIST}</select></td>
	</tr>

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

	<tr>
	  <td class="row1">{L_ATTACHED_FORUM}</td>
	  <td class="row2"><input type="text" name="attached_forum_id" value="{S_ATTACHED_FORUM_ID}" class="post" /><br />{L_ATTACHED_DESC}</td>
	</tr>

#
#-----[ OPEN ]------------------------------------------------
#
	index.php

#
#-----[ FIND ]------------------------------------------------
#
	$forum_id = $forum_data[$j]['forum_id'];

#
#-----[ AFTER, ADD ]------------------------------------------
#
	// Added by Harishankar's Attached Forums MOD
	$attached_id = $forum_data[$j]['attached_forum_id'];
	// End add

#
#-----[ FIND ]------------------------------------------------
#
	
	if ( $is_auth_ary[$forum_id]['auth_view'] )

#
#-----[ REPLACE WITH ]----------------------------------------
#
	
	if ( $is_auth_ary[$forum_id]['auth_view'] && $attached_id == -1 )

#
#-----[ FIND ]------------------------------------------------
#
	
	if ( $forum_data[$j]['forum_status'] == FORUM_LOCKED )
	{
		$folder_image = $images['forum_locked']; 
		$folder_alt = $lang['Forum_locked'];
	}
	
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
	// Added by Harishankar's Attached Forums MOD
	$sql2 = "SELECT forum_name, forum_id FROM " . FORUMS_TABLE . "
			WHERE attached_forum_id = " . $forum_id ;
	$result2 = $db->sql_query ($sql2);
	$list_of_attached = '';
	
	if (! $result2 )
	{
		message_die(GENERAL_ERROR, 'Could not get attached forums.', '', __LINE__, __FILE__, $sql);
	}
	$count_attached = $db->sql_numrows ($result2);
	if ($count_attached == 1)
		$list_of_attached = $lang['Attached_forum'] . ': ';
	else if ($count_attached > 1)
		$list_of_attached = $lang['Attached_forums'] . ': ';
	
	if ($count_attached != 0)
	{
		$row2 = $db->sql_fetchrow ($result2);
		do
		{
			if ($row2)
			{
				$url_row2 = '<a href="' . append_sid ('viewforum.php?f=' . $row2['forum_id'] ) . '">' . $row2['forum_name'] . '</a>' ;
				
				$list_of_attached = $list_of_attached . $url_row2 ;
			}
			$row2 = $db->sql_fetchrow ($result2);
			if ( $row2 )
				$list_of_attached = $list_of_attached . ', ';
		}
		while ($row2);
		
		$list_of_attached = $list_of_attached . '<br />' ;
	}
	
	$db->sql_freeresult ($result2);
	// End add

#
#-----[ FIND ]------------------------------------------------
#
	'LAST_POST' => $last_post,

#
#-----[ AFTER, ADD ]------------------------------------------
#
	// Added by Harishankar's Attached Forums MOD
	'ATTACHED_FORUMS_LIST' => $list_of_attached,
	// End add

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

#
#-----[ FIND ]------------------------------------------------
#
	<span class="gensmall">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}</span>

#
#-----[ AFTER, ADD ]------------------------------------------
#
	<br /><span class="genmed">{catrow.forumrow.ATTACHED_FORUMS_LIST}</span>

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

#
#-----[ FIND ]------------------------------------------------
#
	//
	// Okay, lets dump out the page ...
	//

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

	// Added by Harishankar's Attached Forums MOD
	$sql2 = "SELECT * FROM " . FORUMS_TABLE . 
			" WHERE attached_forum_id = " . $forum_id ;
			
	$result2 = $db->sql_query ($sql2);
	if (! $result2 )
	{
		message_die ('Could not gather attached forum info', __LINE__, __FILE__, $sql2);
	}
	if ($db->sql_numrows ($result2) != 0)
	{
		if ($db->sql_numrows ($result2) == 1)
			$attached_forum_title = $lang['Attached_forum'];
		else
			$attached_forum_title = $lang['Attached_forums'];
		
		$template->assign_block_vars ('switch_attached_list',
									array( 'L_ATTACHED_FORUM' => $attached_forum_title,
										   'L_ATTACHED_TOPICS' => $lang['Topics'],
										   'L_ATTACHED_POSTS' => $lang['Posts']
										 )
									 );
		while ( $row2 = $db->sql_fetchrow ($result2) )
		{
			$attach_forum_name = '<a href="' . append_sid('viewforum.php?f=' . $row2['forum_id']) . '">' . $row2['forum_name'] . '</a>' ;
			$attach_forum_desc = '<br />' . $row2['forum_desc'];
			
			$attach_forum_topics = $row2['forum_topics'];
			$attach_forum_posts = $row2['forum_posts'];
			
			$last_post_id = $row2['forum_last_post_id'];
		
			$template->assign_block_vars ('switch_attached_list.switch_attached_present',
											array 
											(
											'FORUM_NAME' => $attach_forum_name,
											'FORUM_DESC' => $attach_forum_desc,
											'TOPICS' => $attach_forum_topics,
											'POSTS' => $attach_forum_posts
											)
										);
		}	
	}
	
	$db->sql_freeresult ($result2);
	// End add

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

#
#-----[ FIND ]------------------------------------------------
#
	<table border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline">

#
#-----[ BEFORE, ADD ]-----------------------------------------
#
	
	<!-- BEGIN switch_attached_list -->
	<br />
	<table width="100%" border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline">
	  <tr> 
		<th colspan="1" class="thCornerL" height="15" nowrap="nowrap">&nbsp;{switch_attached_list.L_ATTACHED_FORUM}&nbsp;</th>
		<th width="50" class="thTop" nowrap="nowrap">&nbsp;{switch_attached_list.L_ATTACHED_TOPICS}&nbsp;</th>
		<th width="50" class="thTop" nowrap="nowrap">&nbsp;{switch_attached_list.L_ATTACHED_POSTS}&nbsp;</th>
	  </tr>
	  <!-- BEGIN switch_attached_present -->
	  <tr>
		<td class="row1" width="75%"><span class="forumlink">{switch_attached_list.switch_attached_present.FORUM_NAME}</span><span class="genmed">{switch_attached_list.switch_attached_present.FORUM_DESC}</span></td>
		<td class="row2" align="center" valign="middle"><span class="gensmall">{switch_attached_list.switch_attached_present.TOPICS}</span></td>
		<td class="row2" align="center" valign="middle"><span class="gensmall">{switch_attached_list.switch_attached_present.POSTS}</span></td>
  	  </tr>
	  <!-- END switch_attached_present -->
	</table>
	<br />
	<!-- END switch_attached_list -->

#
#-----[ OPEN ]------------------------------------------------
#
     language/lang_english/lang_admin.php
	 
#
#-----[ FIND ]------------------------------------------------
#
	//
	// That's all Folks!

#
#-----[ BEFORE, ADD ]-----------------------------------------
#
	// Added by Harishankar's Attached Forums MOD
	$lang['Attached_Field_Title'] = 'Attached to forum';
	$lang['Attached_Description'] = "This field has been added by Harishankar's attached forums mod. If you wish this forum to be a pseudo sub-forum or attached to another forum, then enter the id of the forum you wish to attach it to. For regular (normal) forums, leave this value as -1";
	// End Add
	
#
#-----[ OPEN ]------------------------------------------------
#
    language/lang_english/lang_main.php
	 
#
#-----[ FIND ]------------------------------------------------
#
	//
	// That's all, Folks!

#
#-----[ BEFORE, ADD ]-----------------------------------------
#

	// Added by Harishankar's Attached Forums MOD

	$lang['Attached_forum'] = 'Attached Forum';
	$lang['Attached_forums'] = 'Attached Forums';
	
	// End Add

#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM
Last edited by harishankar on Sat Dec 11, 2004 8:26 am, edited 5 times in total.

User avatar
battye
Extension Customisations
Extension Customisations
Posts: 10940
Joined: Wed Feb 11, 2004 11:02 am
Location: Australia
Contact:

Post by battye » Thu Dec 09, 2004 12:42 pm

awesome, id love to see this in action. any demo links? :D
Customisations Team Member

https://github.com/battye/php-array-parser - Give it a Star! :D

dying4004
Registered User
Posts: 165
Joined: Mon Nov 17, 2003 8:39 pm

Post by dying4004 » Thu Dec 09, 2004 1:13 pm

just added this to my forum. WORKS FINE. man u r a darling. i always wanted to add CH mod but couldnt add as this blocks many other mods.
but ur mod works like a charm. THNX VERY MUCH for this mod

encryption
Registered User
Posts: 392
Joined: Tue Jul 08, 2003 2:07 pm
Contact:

Post by encryption » Thu Dec 09, 2004 1:44 pm

^^ got a demo ?

-e-

User avatar
harishankar
Registered User
Posts: 99
Joined: Tue Oct 26, 2004 3:37 pm
Contact:

Post by harishankar » Thu Dec 09, 2004 1:44 pm

Thanks :)
Can anybody confirm whether it works with EasyMOD or not? I didn't do this with easyMOD.

I'll upload screenshots of this MOD with both the forum and index display and the admin interface.

It's very simple to use:

1. Go to forum admin -> management. Select edit a forum.
2. You can type the ID of the forum to attach to. To leave a forum unattached, type -1 as the value.
3. Don't attach hidden forums to public forums. I haven't used authentication checking yet.
4. Don't attach a forum to another forum which is attached. For ex. If

>> Correct:

Forum A = unattached
Forum B = attached to A.

>> Wrong:

Forum A = attached to (any)
Forum B = attached to A

Because attached forums will not be displayed on index.

There are no limitations as far as category goes. You can attach a forum X of category M to another forum Y of category N, as long as Y is unattached to any other forum.

Hope I make sense. :) If you have any doubts, please ask.

User avatar
battye
Extension Customisations
Extension Customisations
Posts: 10940
Joined: Wed Feb 11, 2004 11:02 am
Location: Australia
Contact:

Post by battye » Thu Dec 09, 2004 2:08 pm

harishankar wrote: Thanks :)
Can anybody confirm whether it works with EasyMOD or not? I didn't do this with easyMOD.

I'll upload screenshots of this MOD with both the forum and index display and the admin interface.

It's very simple to use:

1. Go to forum admin -> management. Select edit a forum.
2. You can type the ID of the forum to attach to. To leave a forum unattached, type -1 as the value.
3. Don't attach hidden forums to public forums. I haven't used authentication checking yet.
4. Don't attach a forum to another forum which is attached. For ex. If

>> Correct:

Forum A = unattached
Forum B = attached to A.

>> Wrong:

Forum A = attached to (any)
Forum B = attached to A

Because attached forums will not be displayed on index.

There are no limitations as far as category goes. You can attach a forum X of category M to another forum Y of category N, as long as Y is unattached to any other forum.

Hope I make sense. :) If you have any doubts, please ask.


After a lot of editing, I got it to work with EasyMod. admin_forums.php around HTTP_POST_VARS[CAT... was a problem, also index_body.tpl needs the /templates/subSilver and the lang_admin.php didn't like the thats all folks or something
Customisations Team Member

https://github.com/battye/php-array-parser - Give it a Star! :D

User avatar
harishankar
Registered User
Posts: 99
Joined: Tue Oct 26, 2004 3:37 pm
Contact:

Post by harishankar » Thu Dec 09, 2004 2:27 pm

Screenshot Images no longer required so removed to conserve bandwidth on my site.
Last edited by harishankar on Fri Jan 21, 2005 3:27 pm, edited 1 time in total.

User avatar
harishankar
Registered User
Posts: 99
Joined: Tue Oct 26, 2004 3:37 pm
Contact:

Post by harishankar » Thu Dec 09, 2004 2:33 pm

battye wrote: After a lot of editing, I got it to work with EasyMod. admin_forums.php around HTTP_POST_VARS[CAT... was a problem, also index_body.tpl needs the /templates/subSilver and the lang_admin.php didn't like the thats all folks or something

Thanks! I corrected the templates/subSilver part.

What version phpBB do you use?
I worked on a fresh install of phpBB 2.0.11 with no other mods installed.

Some older versions may have:

"That's all Folks!"

instead of

"That's all, Folks!"

User avatar
battye
Extension Customisations
Extension Customisations
Posts: 10940
Joined: Wed Feb 11, 2004 11:02 am
Location: Australia
Contact:

Post by battye » Thu Dec 09, 2004 2:40 pm

in my test environment: 2.0.10

//
// That's all Folks!
// -------------------------------------------------

two suggestions (i really like what you have so far)
can you make Attached Forums: on the index not bold, basically so it matches Moderators, and in viewforums.php, can you remove the Attached Forums thing, and make the Forum in the blue cellpic, SubForums and can you align topics with replies and posts with views, if you can this would make it perfect. also are the moderators of the parent forum also moderators of the subforum? because in the picture it doesnt show. thanks! :D
Customisations Team Member

https://github.com/battye/php-array-parser - Give it a Star! :D

User avatar
harishankar
Registered User
Posts: 99
Joined: Tue Oct 26, 2004 3:37 pm
Contact:

Post by harishankar » Thu Dec 09, 2004 2:46 pm

There are *no* dependent sub-forums. And no, moderators are not carried over from one forum to another. Each forum is independent. This mod just changes the way the forums are displayed.

I've not displayed the moderators on the viewforum.php part yet. Too much like work :roll: If anybody can add that functionality I'll be glad to give them credits in the release version.

The other cosmetic changes can be made in the template files :).

I'll work on those suggestions :D

User avatar
battye
Extension Customisations
Extension Customisations
Posts: 10940
Joined: Wed Feb 11, 2004 11:02 am
Location: Australia
Contact:

Post by battye » Thu Dec 09, 2004 2:55 pm

the main one that is important is the layout, like topics aligned with replies / posts with views. the others can be changed through lang_main.php i presume but this one I'm not sure how to do. thanks a lot mate ! :D :D 8) 8)
Customisations Team Member

https://github.com/battye/php-array-parser - Give it a Star! :D

User avatar
harishankar
Registered User
Posts: 99
Joined: Tue Oct 26, 2004 3:37 pm
Contact:

Post by harishankar » Thu Dec 09, 2004 2:58 pm

battye wrote: the main one that is important is the layout, like topics aligned with replies / posts with views. the others can be changed through lang_main.php i presume but this one I'm not sure how to do. thanks a lot mate ! :D :D 8) 8)


What exactly is unaligned? I cannot follow you. Can you give me a screenshot of this exact problem?

User avatar
harishankar
Registered User
Posts: 99
Joined: Tue Oct 26, 2004 3:37 pm
Contact:

Post by harishankar » Fri Dec 10, 2004 8:01 am

Can somebody give me some feed back on how long it takes to install this MOD by hand and also whether installation level should be "easy" or "intermediate"?

I'll probably be releasing the MOD with a few small changes after some more feedback.

dying4004
Registered User
Posts: 165
Joined: Mon Nov 17, 2003 8:39 pm

Post by dying4004 » Fri Dec 10, 2004 9:43 am

harishankar: its pretty ez to install the mod and took me around 10 mins to install it.

brother i have a request. could u plz integrate 'Last post topic on index' with ur mod plz?? it would be realy grt. thnx very much

User avatar
battye
Extension Customisations
Extension Customisations
Posts: 10940
Joined: Wed Feb 11, 2004 11:02 am
Location: Australia
Contact:

Post by battye » Fri Dec 10, 2004 10:19 am

harishankar wrote:
battye wrote:the main one that is important is the layout, like topics aligned with replies / posts with views. the others can be changed through lang_main.php i presume but this one I'm not sure how to do. thanks a lot mate ! :D :D 8) 8)


What exactly is unaligned? I cannot follow you. Can you give me a screenshot of this exact problem?


Image

So like "Topics" begins where "Replies" in the real forum begins, and "Posts" begins where "Views" in the real forum begins :D
Customisations Team Member

https://github.com/battye/php-array-parser - Give it a Star! :D

Post Reply

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