[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.
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 »

Uhh.. open your eyes?

The main index
Image


A viewforum page
Image

My site in action of it
http://forums.insyderonline.com

cyber5000
Registered User
Posts: 13
Joined: Mon Jan 31, 2005 12:39 am

Post by cyber5000 »

Uhh.. open your eyes?


yes, now there sub forums.
Before i can`t see any sub forum.

i can`t see images at your forum, the are only red crosses!


feedbag
Registered User
Posts: 40
Joined: Fri Jul 23, 2004 8:34 pm

Post by feedbag »

so can the subforums show new posts icon?

503Savage
Registered User
Posts: 7
Joined: Tue Nov 02, 2004 12:29 pm

Post by 503Savage »

What am I doing wrong?
Could not get attached forums.

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip FROM phpbb_users u, phpbb_sessions s WHERE u.user_id = s.session_user_id AND s.session_time >= 1110548818 ORDER BY u.username ASC, s.session_ip ASC

Line : 334
File : /home/kalm1npk/public_html/forums/index.php

Scali
Registered User
Posts: 51
Joined: Wed Dec 01, 2004 8:54 pm
Location: http://www.monloup.net
Contact:

Post by Scali »

feedbag wrote: so can the subforums show new posts icon?


It will be a very good possibility !


niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

A few improvements for this mod:



1) We can check unread topics for subforums by converting piece of native phpBB code to function - we will use the same function to check unread topics for regular forums:

Code: Select all

//check unread topics in each forum (put it on top of index.php)
function check_unread($forum_id)
{
global $new_topic_data, $tracking_topics, $tracking_forums, $HTTP_COOKIE_VARS, $board_config;
	if ( !empty($new_topic_data[$forum_id]) )
	{
		$forum_last_post_time = 0;

		while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
		{
			if ( empty($tracking_topics[$check_topic_id]) )
			{
				$unread_topics = true;
				$forum_last_post_time = max($check_post_time, $forum_last_post_time);

			}
			else
			{
				if ( $tracking_topics[$check_topic_id] < $check_post_time )
				{
					$unread_topics = true;
					$forum_last_post_time = max($check_post_time, $forum_last_post_time);
				}
			}
		}

		if ( !empty($tracking_forums[$forum_id]) )
		{
			if ( $tracking_forums[$forum_id] > $forum_last_post_time )
			{
				$unread_topics = false;
			}
		}

		if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
		{
			if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
			{
				$unread_topics = false;
			}
		}

	}

return $unread_topics;

}
2) On index.php we do not need to have extra SQL querries to find out subforums - we already have all the data we need. We also assign Image for "no new posts" subforums and Image for subforums that have unread posts:

after:

Code: Select all

while( $row = $db->sql_fetchrow($result) )
	{
		$forum_data[] = $row;
	}
we add:

Code: Select all

$attach=$forum_data;
and instead of mod code we use this to find subforums and read unread status - it will display :

Code: Select all

 
   $attached_id = $forum_data[$j]['attached_forum_id'];

						if ( $is_auth_ary[$forum_id]['auth_view'] && $attached_id == -1 )
						{

						$url_row2='';
						$list_of_attached='';
						$a=0;
						foreach ($attach as $key => $value) {
							$sub_forum_id=	$value['forum_id'];
						   if ($value['attached_forum_id']==$forum_id && $is_auth_ary[$sub_forum_id]['auth_view'])
						   {
									$unread_topics = false;
									if ( $userdata['session_logged_in'] )
									{
										if (check_unread($value['forum_id']))
										{
											$url_row2 = '&nbsp;<img src="' . $images['icon_minipost_new'] . '" border="0" alt="' . $lang['New_posts'] . '" title="' . $lang['New_posts'] . '" />';
										}
										else
										{
											$url_row2 = '&nbsp;<img src="' . $images['icon_minipost'] . '" border="0" alt="' . $lang['No_new_posts'] . '" title="' . $lang['No_new_posts'] . '" />';

										}
									}
									else
									{
											$url_row2 = '&nbsp;<img src="' . $images['icon_minipost'] . '" border="0" alt="' . $lang['No_new_posts'] . '" title="' . $lang['No_new_posts'] . '" />';
									}

									$url_row2 .= '<a href="' . append_sid ('viewforum.php?f=' . $value['forum_id'] ) . '">' . $value['forum_name'] . '</a>' ;
									$list_of_attached = $list_of_attached . $url_row2 ;
									$a++;

						   }
						}
						if ($a == 1)
						{
							$list_of_attached = '<span class="genmed">&nbsp;'. $lang['Attached_forum'] . ':'.$list_of_attached.'</span>';
						}
						else if ($a > 1)
						{
							$list_of_attached = '<span class="genmed">&nbsp;'. $lang['Attached_forums'] . ':'.$list_of_attached.'</span>';
						}
						else
						{
							$list_of_attached = '';
						}

3) in viewforum.php we can prevent SQL calls for forums that do not have subforums

on top find:

Code: Select all

if ( !empty($forum_id) )
{
	$sql = "SELECT *
		FROM " . FORUMS_TABLE . "
		WHERE forum_id = $forum_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
	}
}
else
{
	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}

//
// If the query doesn't return any rows this isn't a valid forum. Inform
// the user.
//
if ( !($forum_row = $db->sql_fetchrow($result)) )
{
	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}
replace with:

Code: Select all

if ( !empty($forum_id) )
{
	$sql = "SELECT *
		FROM " . FORUMS_TABLE . "
		WHERE forum_id = $forum_id OR attached_forum_id =$forum_id
		ORDER BY attached_forum_id ASC";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
	}
}
else
{
	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}

//
// If the query doesn't return any rows this isn't a valid forum. Inform
// the user.
//
if ( !($forum_row = $db->sql_fetchrow($result)) )
{
	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}
$attachments='';
if ($db->sql_numrows ($result) > 1)
{
	$attachments=TRUE;
}
then instead of native mod code we use this - this code will check if user is authorized to view any of attached subforums:

Code: Select all

if ($attachments)
{
	   // Added by Harishankar's Attached Forums MOD
	 //  $sql2 = "SELECT * FROM " . FORUMS_TABLE .
	 //        " WHERE attached_forum_id = " . $forum_id ;
		$sql2 = "SELECT f.*, p.post_time, p.post_username,p.poster_ip, u.user_level, u.username, u.user_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 )
			WHERE attached_forum_id = " . $forum_id . "
			ORDER BY f.forum_order";

		$result2 = $db->sql_query ($sql2);
		if (!$result2 )
		{
			message_die ('Could not gather attached forum info', __LINE__, __FILE__, $sql2);
		}

		if ($db->sql_numrows ($result2) != 0)
		{
			while( $row = $db->sql_fetchrow($result2) )
			{
				$forum_data[] = $row;
			}
			$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);

			$x=0;
			foreach ($forum_data as $row2 => $value)
			{
				if ($is_auth_ary[$value['forum_id']]['auth_view'])
				{
					$x++;
					if ($x==1)
					{
						$template->assign_block_vars ('switch_attached_list',
								   array( 'L_ATTACHED_FORUM' => $lang['Attached_forums'],
										 'L_ATTACHED_TOPICS' => $lang['Topics'],
										 'L_ATTACHED_POSTS' => $lang['Posts'],
										 'L_LAST_POST'=>$lang['Last_Post']
									   )
									);

					}
					$attach_forum_name = '<a href="' . append_sid('viewforum.php?f=' . $value['forum_id']) . '">' . $value['forum_name'] . '</a>' ;
					$attach_forum_desc = '<br />' . $value['forum_desc'];
					$attach_forum_topics = $value['forum_topics'];
					$attach_forum_posts = $value['forum_posts'];
					$last_post_id = $value['forum_last_post_id'];


					if ( $value['forum_last_post_id'] )
					{
						$last_post_time = create_date($board_config['default_dateformat'], $value['post_time'], $board_config['board_timezone']);

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

						if ( $value['user_level'] > 0 )
						{
							$style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
						}
						else
						{
							$style_color = '';
						}
						
						$last_post .= ( $value['user_id'] == ANONYMOUS ) ? ''.( ($value['post_username'] != '' ) ? $value['post_username'] . ' ' : $lang['Guest'] . ' ' ).'' : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $value['user_id']) . '" '. $style_color.'>' . $value['username'] . '</a> ';


					}
					else
					{
						$last_post = $lang['No_Posts'];
					}

$template->assign_block_vars ('switch_attached_list.switch_attached_present',
										 array
										 (
										 'FORUM_NAME' => "$url_value &nbsp; $attach_forum_name",
										 'FORUM_DESC' => $attach_forum_desc,
										 'TOPICS' => $attach_forum_topics,
										 'POSTS' => $attach_forum_posts,
										 'LAST_POST_ID' => $last_post,
										 ));
				}
		}

	}
	   $db->sql_freeresult ($result2);
}
   // End add
Don't forget to add function check_unread() for regular topics in index.php. Cheers.

Virtual4Ever
Registered User
Posts: 6
Joined: Thu Jan 27, 2005 5:19 pm
Location: Petrosani, Romania
Contact:

Post by Virtual4Ever »

I suggest to post the full working .mod file or something, it`s really hard to follow all this posts.

Thallium
Registered User
Posts: 395
Joined: Mon Aug 30, 2004 12:30 am
Contact:

Post by Thallium »

Virtual4Ever wrote: I suggest to post the full working .mod file or something, it`s really hard to follow all this posts.

Agreed. It looks like niekas has made the breakthrough I've been waiting for! :lol:

If this works it's gonna be BIG. I'm going to set up a test board and try to put all these snippets together, but whoever is in charge really should compile a .mod now that the flag unread issue seems on the verge of breaking. :D

---Thallium
Complete phpBB powered websites, Mods/Hacks installed, unique templates, updates and repairs... reasonable. Email, PM or IM.

User avatar
smithy_dll
Former Team Member
Posts: 7630
Joined: Tue Jan 08, 2002 6:27 am
Location: Australia
Name: Lachlan Smith
Contact:

Post by smithy_dll »

Hello,

Could you please change your MODs version number as outlined in MOD Development forum rules section 2. Your MOD as being in development requires a development version number as stated in the phpBB versioning scheme.

For example if your MOD is currently displaying v1.0.0, you can change it to 0.1.0 or 1.1.0, depending on your feelings of it's development status. Even minor version numbers (y of x.y.z) are reserved for release versions. If you believe your MOD is of a quality that deserves a release version, please do not hesitate to submit your MOD to the phpBB.com MODDB (MOD release database) for validation pending release.

Thank you,
The phpBB MOD Team

Dan39
Registered User
Posts: 186
Joined: Tue Apr 20, 2004 12:39 am
Contact:

Post by Dan39 »

nice mod except..

YOU FUCKING SUCK AT MAKIGN INSTALL DIRECTIONS omg they have been pissing me off, before every single line of code is like an extra tab of spaces, which is not fuckinf needed, just makes it lot more difficult when finding, and copyin/pasting stuff

User avatar
stickerboy
Former Team Member
Posts: 7349
Joined: Mon Mar 29, 2004 2:27 pm
Location: Airdrie, UK (127.0.0.1)
Name: Kenny Cameron
Contact:

Post by stickerboy »

Dan39 wrote: nice mod except..

YOU *beep* SUCK AT MAKIGN INSTALL DIRECTIONS omg they have been *beep* me off, before every single line of code is like an extra tab of spaces, which is not *beep* needed, just makes it lot more difficult when finding, and copyin/pasting stuff

which is exactly why this MOD is in the BETA FORUM.
If you feel you can do better, please do so.
if not, please do make such comments :roll:

I had no problems installing this MOD, and that includes ALL of the updates posted
(ok i had a few issues, but they faults of my own)
I'm a web-designing code-decrypting tech-support musician
|| Twitter || Flickr || phpBB Snippets ||
Formerly known as cherokee red

niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

I put together my improvements for this mod in one install file. Read my notes on MOD History below:

Code: Select all

##############################################################
## MOD Title: Attached forums or pseudo sub-forums MOD
## MOD Author: harishankar < v_harishankar@yahoo.co.in > (Harishankar) http://literaryforums.org (improved and optimized by niekas)
## 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.2 (beta)
##
## 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:
##
##   2005-03-25 - Version 1.0.2
##   -Improved index generation - removed database querries inside the loop
##   -Added indicator for new subforum posts on index
##   -No database querries on viewforum.php if forum has no subforums
##   -Added last post link on subforums on viewforum.php
##   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 ]------------------------------------------------
#

include($phpbb_root_path . 'common.'.$phpEx);


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

function check_unread($forum_id)
{
global $new_topic_data, $tracking_topics, $tracking_forums, $HTTP_COOKIE_VARS, $board_config;
   if ( !empty($new_topic_data[$forum_id]) )
   {
      $forum_last_post_time = 0;

      while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
      {
         if ( empty($tracking_topics[$check_topic_id]) )
         {
            $unread_topics = true;
            $forum_last_post_time = max($check_post_time, $forum_last_post_time);

         }
         else
         {
            if ( $tracking_topics[$check_topic_id] < $check_post_time )
            {
               $unread_topics = true;
               $forum_last_post_time = max($check_post_time, $forum_last_post_time);
            }
         }
      }

      if ( !empty($tracking_forums[$forum_id]) )
      {
         if ( $tracking_forums[$forum_id] > $forum_last_post_time )
         {
            $unread_topics = false;
         }
      }

      if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
      {
         if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
         {
            $unread_topics = false;
         }
      }

   }

return $unread_topics;

} 

#
#-----[ FIND ]------------------------------------------------
#
	{
		$forum_data[] = $row;
	}
#
#-----[ AFTER, ADD ]------------------------------------------
#
	
	$attach=$forum_data;
	
#
#-----[ FIND ]------------------------------------------------
#
   $forum_id = $forum_data[$j]['forum_id'];

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


   $attached_id = $forum_data[$j]['attached_forum_id'];
						if ( $is_auth_ary[$forum_id]['auth_view'] && $attached_id == -1 )
						{

						$url_row2='';
						$list_of_attached='';
						$a=0;
						foreach ($attach as $key => $value) {
							$sub_forum_id=	$value['forum_id'];
						   if ($value['attached_forum_id']==$forum_id && $is_auth_ary[$sub_forum_id]['auth_view'])
						   {
									$unread_topics = false;
									if ( $userdata['session_logged_in'] )
									{
										if (check_unread($value['forum_id']))
										{
											$url_row2 = '&nbsp;<img src="' . $images['icon_minipost_new'] . '" border="0" alt="' . $lang['New_posts'] . '" title="' . $lang['New_posts'] . '" />';
										}
										else
										{
											$url_row2 = '&nbsp;<img src="' . $images['icon_minipost'] . '" border="0" alt="' . $lang['No_new_posts'] . '" title="' . $lang['No_new_posts'] . '" />';

										}
									}
									else
									{
											$url_row2 = '&nbsp;<img src="' . $images['icon_minipost'] . '" border="0" alt="' . $lang['No_new_posts'] . '" title="' . $lang['No_new_posts'] . '" />';
									}

									$url_row2 .= '<a href="' . append_sid ('viewforum.php?f=' . $value['forum_id'] ) . '">' . $value['forum_name'] . '</a>' ;
									$list_of_attached = $list_of_attached . $url_row2 ;
									$a++;

						   }
						}
						if ($a == 1)
						{
							$list_of_attached = '<span class="genmed">'. $lang['Attached_forum'] . ':'.$list_of_attached.'</span>';
						}
						else if ($a > 1)
						{
							$list_of_attached = '<span class="genmed">'. $lang['Attached_forums'] . ':'.$list_of_attached.'</span>';
						}
						else
						{
							$list_of_attached = '';
						}

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


									if ( !empty($new_topic_data[$forum_id]) )
									{
										$forum_last_post_time = 0;

										while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
										{
											if ( empty($tracking_topics[$check_topic_id]) )
											{
												$unread_topics = true;
												$forum_last_post_time = max($check_post_time, $forum_last_post_time);

											}
											else
											{
												if ( $tracking_topics[$check_topic_id] < $check_post_time )
												{
													$unread_topics = true;
													$forum_last_post_time = max($check_post_time, $forum_last_post_time);
												}
											}
										}

										if ( !empty($tracking_forums[$forum_id]) )
										{
											if ( $tracking_forums[$forum_id] > $forum_last_post_time )
											{
												$unread_topics = false;
											}
										}

										if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
										{
											if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
											{
												$unread_topics = false;
											}
										}

									}


#
#-----[ REPLACE WITH ]----------------------------------------
#

$unread_topics=check_unread($forum_id);

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

#
#-----[ AFTER, ADD ]------------------------------------------
#
   'ATTACHED_FORUMS_LIST' => $list_of_attached,

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

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

#
#-----[ AFTER, ADD ]------------------------------------------
#
   <br />{catrow.forumrow.ATTACHED_FORUMS_LIST}

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

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

	$sql = "SELECT *
		FROM " . FORUMS_TABLE . "
		WHERE forum_id = $forum_id";
#
#-----[ REPLACE WITH ]----------------------------------------
#

	$sql = "SELECT *
		FROM " . FORUMS_TABLE . "
		WHERE forum_id = $forum_id OR attached_forum_id =$forum_id
		ORDER BY attached_forum_id ASC";

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


if ( !($forum_row = $db->sql_fetchrow($result)) )
{
	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}

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

$attachments='';
if ($db->sql_numrows ($result) > 1)
{
	$attachments=TRUE;
}

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

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

if ($attachments)
{
		$sql2 = "SELECT f.*, p.post_time, p.post_username,p.poster_ip, u.user_level, u.username, u.user_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 )
			WHERE attached_forum_id = " . $forum_id . "
			ORDER BY f.forum_order";

		$result2 = $db->sql_query ($sql2);
		if (!$result2 )
		{
			message_die ('Could not gather attached forum info', __LINE__, __FILE__, $sql2);
		}

		if ($db->sql_numrows ($result2) != 0)
		{
			while( $row = $db->sql_fetchrow($result2) )
			{
				$forum_data[] = $row;
			}
			$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);

			$x=0;
			foreach ($forum_data as $row2 => $value)
			{
				if ($is_auth_ary[$value['forum_id']]['auth_view'])
				{
					$x++;
					if ($x==1)
					{
						$template->assign_block_vars ('switch_attached_list',
								   array( 'L_ATTACHED_FORUM' => $lang['Attached_forums'],
										 'L_ATTACHED_TOPICS' => $lang['Topics'],
										 'L_ATTACHED_POSTS' => $lang['Posts'],
										 'L_LAST_POST'=>$lang['Last_Post']
									   )
									);

					}
					$attach_forum_name = '<a href="' . append_sid('viewforum.php?f=' . $value['forum_id']) . '">' . $value['forum_name'] . '</a>' ;
					$attach_forum_desc = '<br />' . $value['forum_desc'];
					$attach_forum_topics = $value['forum_topics'];
					$attach_forum_posts = $value['forum_posts'];
					$last_post_id = $value['forum_last_post_id'];


					if ( $value['forum_last_post_id'] )
					{
						$last_post_time = create_date($board_config['default_dateformat'], $value['post_time'], $board_config['board_timezone']);

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

						$last_post .= ( $value['user_id'] == ANONYMOUS ) ? ''.( ($value['post_username'] != '' ) ? $value['post_username'] . ' ' : $lang['Guest'] . ' ' ).'' : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $value['user_id']) . '" '. $style_color.'>' . $value['username'] . '</a> ';

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

$template->assign_block_vars ('switch_attached_list.switch_attached_present',
										 array
										 (
										 'FORUM_NAME' => "$url_value &nbsp; $attach_forum_name",
										 'FORUM_DESC' => $attach_forum_desc,
										 'TOPICS' => $attach_forum_topics,
										 'POSTS' => $attach_forum_posts,
										 'LAST_POST_ID' => $last_post,
										 ));
				}
		}

	}
	   $db->sql_freeresult ($result2);
}

#
#-----[ 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 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>
	  <th width="50" class="thTop" nowrap="nowrap">&nbsp;{switch_attached_list.L_LAST_POST}&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>
	  <td class="row2" align="center" nowrap="nowrap" valign="middle"><span class="gensmall">{switch_attached_list.switch_attached_present.LAST_POST_ID}</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

theanimewizard
Registered User
Posts: 646
Joined: Tue Jul 08, 2003 9:24 pm
Contact:

Post by theanimewizard »

question:

so basically, the sub forums are REGULAR FORUMS that are just displayed as sub forums in the index and view forum page.

any changes like permissions etc can still be changed in the acp right?

Post Reply

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