[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
niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

chesster wrote: Right now even though on paper the mod can only have 1 level of hierarchy ( you can't have sub-subforum). However, a forum CAN attach to another forum which is already a subforum of something else. The topic/thread count however isn't counted properly.

Another suggestion:

+ This should not be allowed. It isn't in the spec. And it may have consequences.


Overall, it's a good mod. THanks.


1.0.5v doesn't allow you to attach forum to subforum. It is impossible through ACP.

What is wrong with topic thread count?

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

Post by Merri »

I want to hear about the impossible part again: phpBB templating system is very flexible if you just use it. You can well leave all HTML for the templates... I don't know why they didn't do so in the first place. Anyways, here is what I've done this far to claim my words here:

http://konnun.vihrealohikaarme.com/ (only index page changed this far)

Changes on index.php

Code: Select all

			                  if ( $is_auth_ary[$forum_id]['auth_view'] && $attached_id == -1 )
                  			{
				                  $attached_forums = array();
				                  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'])
								{
									//combining topic and post count for forum and subforums
									$forum_data[$j]['forum_posts']=$forum_data[$j]['forum_posts']+$value['forum_posts'];
									$forum_data[$j]['forum_topics']=$forum_data[$j]['forum_topics']+$value['forum_topics'];
									//END combining topic and post count

									//Last post link - check if any of subforums have newest posts and link to them instead
									if ($value['post_time']>$forum_data[$j]['post_time'])
									{
										$forum_data[$j]['user_id'] = $value['user_id'];
										$forum_data[$j]['post_username'] = $value['post_username'];
										$forum_data[$j]['forum_last_post_id'] = $value['forum_last_post_id'];
										$forum_data[$j]['post_time'] = $value['post_time'];
										$forum_data[$j]['username'] = $value['username'];
										$forum_data[$j]['topic_title'] = $value['topic_title'];
									}
									// END last post check

									$unread_topics = false;
									if ( $userdata['session_logged_in'] )
									{
										if (check_unread($value['forum_id']))
										{
											$attach_img = $images['icon_minipost_new'];
											$l_attach_img = $lang['New_posts'];
										}
										else
										{
											$attach_img = $images['icon_minipost'];
											$l_attach_img = $lang['No_new_posts'];
										}
									}
									else
									{
										$attach_img = $images['icon_minipost'];
										$l_attach_img = $lang['No_new_posts'];
									}

									$attached_forums[] = array(
										$attach_img,
										$l_attach_img,
										$value['forum_name'],
										append_sid ('viewforum.php?f=' . $value['forum_id'] )
									);
								}
							}

Code: Select all

							$template->assign_block_vars('catrow.forumrow',	array(
								'ROW_COLOR' => '#' . $row_color,
								'ROW_CLASS' => $row_class,
								'FORUM_FOLDER_IMG' => $folder_image, 
								'FORUM_NAME' => $forum_data[$j]['forum_name'],
								'FORUM_DESC' => $forum_data[$j]['forum_desc'],
// Topic posters MOD, By Manipe (Begin)
								'POSTS' => $posts_topic_posters,
// Topic posters MOD, By Manipe (End)
								'TOPICS' => $forum_data[$j]['forum_topics'],
								'LAST_POST' => $last_post,

								'L_FORUM_FOLDER_ALT' => $folder_alt, 

								'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
							);

							$attached_forum_count = count($attached_forums);
							if($attached_forum_count)
							{
								$template->assign_block_vars('catrow.forumrow.switch_attached_forums', array() );

								for($i = 0; $i < $attached_forum_count; $i++)
								{
									$template->assign_block_vars('catrow.forumrow.attached_forums', array(
										'FORUM_IMAGE' => $attached_forums[$i][0],
										'FORUM_NAME' => $attached_forums[$i][2],

										'L_FORUM_IMAGE' => $attached_forums[$i][1],

										'U_VIEWFORUM' => $attached_forums[$i][3]
									) );
								}
							}
Changes on templates/subSilver/index_body.tpl

Code: Select all

	<td class="row1" width="100%" height="50"><span class="forumlink"> <a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink">{catrow.forumrow.FORUM_NAME}</a><br />
	  </span> <span class="genmed">{catrow.forumrow.FORUM_DESC}<br />
<!-- BEGIN switch_attached_forums -->
<br /><b>{L_ATTACHED_FORUMS}:</b>
<!-- END switch_attached_forums -->
	  <!-- BEGIN attached_forums -->
		<a class="nav" href="{catrow.forumrow.attached_forums.U_VIEWFORUM}"><img alt="{catrow.forumrow.attached_forums.L_FORUM_IMAGE}" border="0" src="{catrow.forumrow.attached_forums.FORUM_IMAGE}" title="{catrow.forumrow.attached_forums.L_FORUM_IMAGE" />[{catrow.forumrow.attached_forums.FORUM_NAME}]</a>
	  <!-- END attached_forums -->
	  </span></td>
Nice and clean, no problems there afaik :)

loosh
Registered User
Posts: 14
Joined: Tue Apr 19, 2005 2:09 am

Post by loosh »

...
Last edited by loosh on Mon May 02, 2005 11:07 pm, edited 1 time in total.

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

Post by Merri »

loosh: The only help I can direct to without doing all the work by myself for you is to guide you to read up about HTML. It seems you don't know much about HTML and without knowing it, you're pretty much helpless each time you want to actually modify your board. The best way you can help yourself is to first learn HTML, then about templates and then, if needed, PHP. Without those skills and will to learn you just give an impression of lazy of yourself.

loosh
Registered User
Posts: 14
Joined: Tue Apr 19, 2005 2:09 am

Post by loosh »

Sorry.
Last edited by loosh on Mon May 02, 2005 11:25 pm, edited 1 time in total.

loosh
Registered User
Posts: 14
Joined: Tue Apr 19, 2005 2:09 am

Post by loosh »

Merri wrote: loosh: The only help I can direct to without doing all the work by myself for you is to guide you to read up about HTML. It seems you don't know much about HTML and without knowing it, you're pretty much helpless each time you want to actually modify your board. The best way you can help yourself is to first learn HTML, then about templates and then, if needed, PHP. Without those skills and will to learn you just give an impression of lazy of yourself.


I would be willing to pay someone to do that for me, or I am a graphic designer and would be willing to exchange services.

loosh
Registered User
Posts: 14
Joined: Tue Apr 19, 2005 2:09 am

Post by loosh »

I just fixed it up to work with the pseudo (before it was giving me all sorts of errors) but i am still having trouble with template compatibility.

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

Post by Merri »

niekas: There is something you can optimize atleast on index.php:

Code: Select all

	// $forum_data = array();
	// while( $row = $db->sql_fetchrow($result) )
	// {
	// 	$forum_data[] = $row;
	// }

	$forum_data = $db->sql_fetchrowset($result);
Does exactly the same, only faster and with shorter code.

yoeddy
Registered User
Posts: 535
Joined: Wed Feb 18, 2004 3:44 am
Location: Boise, Idaho

Post by yoeddy »

niekas,

Could you PM me or post the 1.04 code that you had on page 1 one this thread last week. I want to completely remove this mod and start from scratch as if I never had this mod installed, and then installing with 1.05. I'm kind of a neatnick like that.

Thanks!

loosh
Registered User
Posts: 14
Joined: Tue Apr 19, 2005 2:09 am

Post by loosh »

For the time being I have used another template... but I have one last question (sorry I am posting this much with problems)... http://theorangecollar.com/phpbb2/ is the forum I am working on. The forums are not appearing atall inside the catagories after installing this mod (has anyone else had this problem?) and I am not sure where the sub-forum option is... even though at present it would not do me any good seeing as I cent even create forums that work. Does anyone know how to fix this problem?

would this problem be in the sql??
Last edited by loosh on Tue May 03, 2005 12:29 am, edited 1 time in total.

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

Post by Merri »

loosh: Probably there is an error in your PHP code and it thinks there is no forums at all. Or there is an error in the SQL call. Or some other such as incorrect data in the database.


yoeddy: I have it saved:

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
##               includes/functions.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
##
##############################################################
## MOD History:
##   2005-04-26 - Version 1.0.4
##      -Check new posts on children forums when viewing parent forum
##   
##   2005-04-24 - Version 1.0.3
##      -display latest topic subject on index and subforums
##      -combine parent forum and subforums post and topic count on index
##      -display subforum last post if subforum has newer post than a parent forum
##
##   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,
   
#
#-----[ FIND ]----------------------------------------
#
   VALUES ('" . $next_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 ]------------------------------------------------
#
         $sql = "SELECT f.*, p.post_time, p.post_username, 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 )
            ORDER BY f.cat_id, f.forum_order";
#
#-----[ REPLACE WITH ]----------------------------------------
#

         $sql = "SELECT f.*, p.post_time, p.post_username,  u.username, u.user_id, t.topic_id, t.topic_title
            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";

#
#-----[ 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 ]------------------------------------------------
#
   {
      $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'])
                     {
                        //combining topic and post count for forum and subforums
                        $forum_data[$j]['forum_posts']=$forum_data[$j]['forum_posts']+$value['forum_posts'];
                        $forum_data[$j]['forum_topics']=$forum_data[$j]['forum_topics']+$value['forum_topics'];
                        //END combining topic and post count

                        //Last post link - check if any of subforums have newest posts and link to them instead
                           if ($value['post_time']>$forum_data[$j]['post_time'])
                           {
                              $forum_data[$j]['user_id'] = $value['user_id'];
                              $forum_data[$j]['post_username'] = $value['post_username'];
                              $forum_data[$j]['forum_last_post_id'] = $value['forum_last_post_id'];
                              $forum_data[$j]['post_time'] = $value['post_time'];
                              $forum_data[$j]['username'] = $value['username'];
                              $forum_data[$j]['topic_title'] = $value['topic_title'];
                           }
                        // END last post check

                           $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 ( $forum_data[$j]['forum_last_post_id'] )
                     {
                        $last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']);

                        $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>';
                     }
                     else
                     {
                        $last_post = $lang['No_Posts'];
                     }

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

                     if ( $forum_data[$j]['forum_last_post_id'] )
                     {
                        if (strlen($forum_data[$j]['topic_title'])>=35)
                        {
                           $forum_data[$j]['topic_title']=substr($forum_data[$j]['topic_title'],0,35). "...";
                        }

                        $last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']);
                        $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 /> by ';
                        $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;                        
                     }
                     else
                     {
                        $last_post = $lang['No_Posts'];
                     }


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

#
#-----[ AFTER, ADD ]------------------------------------------
#
   'ATTACHED_FORUMS_LIST' => $list_of_attached,
   
#-----[ FIND ]------------------------------------------------
#
     } // for ... categories

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

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


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

function get_db_stat($mode)
{


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

}

#
#-----[ 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)
{

      //
      // 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'];
         }
      }

      $sql2 = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, t.topic_id, t.topic_title
         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)
         WHERE attached_forum_id = " . $forum_id . "
         GROUP by f.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_status'] == FORUM_LOCKED )
               {
                  $folder_image = $images['forum_locked'];
                  $folder_alt = $lang['Forum_locked'];
               }
               else
               {
                  $unread_topics = false;
                  if ( $userdata['session_logged_in'] )
                  {
                     $unread_topics=check_unread($value['forum_id']);
                  }

                  $folder_image = ( $unread_topics ) ? $images['forum_new'] : $images['forum'];
                  $folder_alt = ( $unread_topics ) ? $lang['New_posts'] : $lang['No_new_posts'];
               }

               if ( $value['forum_last_post_id'] )
               {

                  if (strlen($value['topic_title'])>=35)
                  {
                     $value['topic_title']=substr($value['topic_title'],0,35). "...";
                  }

                  $last_post_time = create_date($board_config['default_dateformat'], $value['post_time'], $board_config['board_timezone']);
                  $last_post = '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $value['forum_last_post_id']) . '#' . $value['forum_last_post_id'] . '">'.$value['topic_title'].' <img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>';

                  $last_post .= '<br /> by ';
                  $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']) . '">' . $value['username'] . '</a> ';
                  $last_post .= ' '.$last_post_time;                        


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

$template->assign_block_vars ('switch_attached_list.switch_attached_present',
                               array
                               (
                              'FORUM_FOLDER_IMG' => $folder_image,
                              'L_FORUM_FOLDER_ALT' => $folder_alt,
                               'FORUM_NAME' => "&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 colspan="2" 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" align="center" valign="middle" height="38"><img src="{switch_attached_list.switch_attached_present.FORUM_FOLDER_IMG}" width="46" height="25" alt="{switch_attached_list.switch_attached_present.L_FORUM_FOLDER_ALT}" title="{switch_attached_list.switch_attached_present.L_FORUM_FOLDER_ALT}" /></td>
      <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
Shouldn't have any modifications, but can't be 100% sure.

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

Post by niekas »

Merri,

thanks a lot for your advise and help. You're right about template - it is flexible enough:

I ironed your code a bit and i'll add it to the the next release.

basically i just added a switch for BR tag in template in case we have no mods listed also reflect subforum vs subforums (one vs multiple subforums). Changed $i to $k because it conflicts with category loop.

Code: Select all

                    $attached_forum_count = count($attached_forums);
                     if($attached_forum_count)
                     {
                       
					   $template->assign_block_vars('catrow.forumrow.switch_attached_forums', array(
                        'L_ATTACHED_FORUMS' => ($attached_forum_count ==1)? $lang['Attached_forum']: $lang['Attached_forums']
						));
						if (count($forum_moderators[$forum_id]) > 0 )
						{
						   $template->assign_block_vars('catrow.forumrow.switch_attached_forums.br', array());
						}
                        for($k = 0; $k < $attached_forum_count; $k++)
                        {
                           $template->assign_block_vars('catrow.forumrow.switch_attached_forums.attached_forums', array(
                              'FORUM_IMAGE' => $attached_forums[$k]['sub_img'],
                              'FORUM_NAME' => $attached_forums[$k]['sub_name'],
                              'L_FORUM_IMAGE' => $attached_forums[$k]['sub_alt'],
                              'U_VIEWFORUM' => $attached_forums[$k]['sub_url']
                           ));
                        }
                     }



template:

Code: Select all

	  <!-- BEGIN switch_attached_forums -->
	  <!-- BEGIN br -->
	  <br />
	  <!-- END br -->
	  <span class="genmed">{catrow.forumrow.switch_attached_forums.L_ATTACHED_FORUMS}:
	       <!-- BEGIN attached_forums -->
	        <a class="nav" href="{catrow.forumrow.switch_attached_forums.attached_forums.U_VIEWFORUM}"><img alt="{catrow.forumrow.switch_attached_forums.attached_forums.L_FORUM_IMAGE}" border="0" src="{catrow.forumrow.switch_attached_forums.attached_forums.FORUM_IMAGE}" title="{catrow.forumrow.switch_attached_forums.attached_forums.L_FORUM_IMAGE" />{catrow.forumrow.switch_attached_forums.attached_forums.FORUM_NAME}</a>
	       <!-- END attached_forums -->
	  <span class="genmed">
	  <!-- END switch_attached_forums -->

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

Post by niekas »

loosh wrote: For the time being I have used another template... but I have one last question (sorry I am posting this much with problems)... http://theorangecollar.com/phpbb2/ is the forum I am working on. The forums are not appearing atall inside the catagories after installing this mod (has anyone else had this problem?) and I am not sure where the sub-forum option is... even though at present it would not do me any good seeing as I cent even create forums that work. Does anyone know how to fix this problem?

would this problem be in the sql??


loosh,

try to set up default phpbb forum (with no mods and no themes) on your local computer. Then install easymod. Use easy mod to install subforum mod. Everything should work fine.

After that add your theme to the board. Try switching to your new theme and see if mod is working correctly with your new theme.

It will help you to understand little by little how the board, themes and mods work together.

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

Post by Merri »

Ah, didn't notice the $i there, thanks. Should have had more categories so I'd have noticed it myself.

At the moment I'm ironing out your code in viewforum.php, I've already fixed and optimized a few things, though not done with it. I'm also including a new feature: categories will be visible so that subforums of different categories sort out correctly. I have some new features in index.php as well. I'll post the code when I'm done so you can see what you might want to change :)

loosh
Registered User
Posts: 14
Joined: Tue Apr 19, 2005 2:09 am

Post by loosh »

How exactly are sub-forums created after this mod is installed?

Locked

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