[2.0.7] Last Topic MOD

The cleanup is complete. This forum is now read only.

Rating:

Excellent!
20
63%
Very Good
5
16%
Good
1
3%
Fair
3
9%
Poor
3
9%
 
Total votes : 32

Postby slewball1 » Sat Mar 19, 2005 11:49 pm

I've fixed it myself...with the help a guardian angel on the other forum. Yes!! It took me a while and lots of try and errors BUT now my forum looks better and well organised!!! :P :P :P :P :P :P :P :P :P :P
slewball1
Registered User
 
Posts: 48
Joined: Sat Feb 12, 2005 4:52 am

MOD to Last Topic on Index (In, By, Alt text)

Postby D¡cky » Sun Mar 20, 2005 2:13 am

Adds:
  • In: before Post Subject
  • By: before Poster Name
  • Alternate text to truncated Subjects
Code: Select all
#
#-----[ OPEN ]------------------------------------------
#

index.php

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


                           $last_post .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$ltid") . '">' . substr($lttitle, 0, 25) . '...</a><br />';

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


                           $last_post .= $lang['in'] . ':&nbsp;' . '<a title="' . $lttitle . '" alt="' . $lttitle . '" href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$ltid") . '">' . substr($lttitle, 0, 25) . '...</a><br />';
#
#-----[ FIND ]------------------------------------------
#

                           $last_post .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$ltid") . '">' . substr($lttitle, 0, 25) . '</a><br />';

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

                           $last_post .= $lang['in'] . ':&nbsp;' . '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$ltid") . '">' . substr($lttitle, 0, 25) . '</a><br />';
                           
#
#-----[ FIND ]------------------------------------------
#

                        $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&amp;" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';

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

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


#
#-----[ OPEN ]------------------------------------------
#

language/lang_english/lang_main.php

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

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

?>

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

// Begin add - Last Topic on Index
$lang['by'] = 'By';
$lang['in'] = 'In';
// End add - Last Topic on Index

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
Have you hugged someone today?
The phpBB.com Unofficial Support Team Forum
phpBB Installers Installations | Custom MODs | Conversions
User avatar
D¡cky
Support Team Member
Support Team Member
 
Posts: 7948
Joined: Tue Jan 25, 2005 8:38 pm
Location: New Hampshire, USA

Postby slewball1 » Sun Mar 20, 2005 11:36 pm

I guess yours is also a different way of doing it. I first edited my viewforum_body.tpl to LEFT align the Last Post info because I didn't like the untidy "centred' look. I found the MOD here. But I only edited the {L_LASTPOST} and {topicrow.LAST_POST_TIME} alignments from "center" and replaced them "LEFT"

Then:
Code: Select all
#
#-----[ OPEN ]------------------------------------------
#

language/lang_english/lang_main.php

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

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

?>

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

// Begin add - Last Topic on Index
$lang['By:'] = 'By:';
$lang['In:'] = 'In:';
// End add - Last Topic on Index

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
#

THEN in index.php page - courtesy of "sonyboy"!! (NOTE that this maybe different from yours because I had already modified my index file with the Last Topic MOD)::

Code: Select all
Open index.php
Find:

$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'] . '">' . substr($lttitle, 0, 25) . '...</a><br />';

Replace with:

$last_post .= '<b>In:</b> <a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '">' . substr($lttitle, 0, 25) . '...</a><br />';

Find:

$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'] . '">' . substr($lttitle, 0, 25) . '</a><br />';

Replace with:

$last_post .= '<b>In:</b> <a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '">' . substr($lttitle, 0, 25) . '</a><br />';

Find:

$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&amp;" . POST_USERS_URL . '=' . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';

Replace with:

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

Save it & done

See my forum
slewball1
Registered User
 
Posts: 48
Joined: Sat Feb 12, 2005 4:52 am

Postby D¡cky » Mon Mar 21, 2005 1:20 am

I like the left aligned items. It does make for a neater look.

I do have a couple of issues with your code. They are probably fine for you, but they may not work for others.

1) Why set the By: and In: in lang_main and then not use them in your code?

2) Your code does not show By: when an Anonymous poster posts. Look at the topic by pixelplace in the Links forum.

My code also has an alternate text flyout when you mouseover a subject that is too long to be fully displayed on the Index.
Have you hugged someone today?
The phpBB.com Unofficial Support Team Forum
phpBB Installers Installations | Custom MODs | Conversions
User avatar
D¡cky
Support Team Member
Support Team Member
 
Posts: 7948
Joined: Tue Jan 25, 2005 8:38 pm
Location: New Hampshire, USA

Postby slewball1 » Mon Mar 21, 2005 6:07 pm

Yes the Left align definitely makes the board a bit neater especially after displaying the Last Topic details.

You have a good point on my adding 'By:' and 'In' to the lang_main file. I particularly did this when I didn't know what I was doing from the beginning. I guess I didn't bother to take them out afterwards:-).

Hmm...yeah I realised it doesn't display 'By' when a guest posts. Why is that so?

If I find my

Code: Select all
$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<b>By:</b> <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';


and replace it with your

Code: Select all
$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? $lang['by'] . ':&nbsp;' . ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : $lang['by'] . ':&nbsp;' . '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';


will that solve it?

Can you also provide a link to your forum so I can see how the alternate text stuff looks like? You can PM me if you don't want to post your forum here..
slewball1
Registered User
 
Posts: 48
Joined: Sat Feb 12, 2005 4:52 am

Postby slewball1 » Mon Mar 21, 2005 8:45 pm

Nevermind I've fixed the Anonymous poster bug! Here is what I did:

Found:

Code: Select all
$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<b>By:</b> <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';


Replaced with:

Code: Select all
$last_post .= ( $forum_data[$j]['user_id'] == ANONYMOUS ) ? '<b>By:</b>'. ( ($forum_data[$j]['post_username'] != '' ) ? $forum_data[$j]['post_username'] . ' ' : $lang['Guest'] . ' ' ) : '<b>By:</b> <a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
slewball1
Registered User
 
Posts: 48
Joined: Sat Feb 12, 2005 4:52 am

Postby D¡cky » Tue Mar 22, 2005 2:06 am

slewball1, yoiu need to put a space after the By: for anonymous posters to keep things neat and tidy.

You can see an example of the alternate text flyout at the Manipe F1 forum. (This is not my forum.) Link is in this post, http://www.phpbb.com/phpBB/viewtopic.ph ... 01#1266601
Have you hugged someone today?
The phpBB.com Unofficial Support Team Forum
phpBB Installers Installations | Custom MODs | Conversions
User avatar
D¡cky
Support Team Member
Support Team Member
 
Posts: 7948
Joined: Tue Jan 25, 2005 8:38 pm
Location: New Hampshire, USA

Postby slewball1 » Tue Mar 22, 2005 8:57 am

D¡cky wrote:slewball1, yoiu need to put a space after the By: for anonymous posters to keep things neat and tidy.


Thanks for pointing that out. I've fixed that. guest can no longer post on that forum anyways but it's still fixed:-)

You can see an example of the alternate text flyout at the Manipe F1 forum. (This is not my forum.) Link is in this post, http://www.phpbb.com/phpBB/viewtopic.ph ... 01#1266601


I've seen what you mean. I'll leave my forum as it is right now.

Thanks again
slewball1
Registered User
 
Posts: 48
Joined: Sat Feb 12, 2005 4:52 am

Postby xeite » Sat Mar 26, 2005 1:06 am

Hello guys and gals. I need some support with this mod.

I was trying two separate mods, first based on e-sven Last topics and second one is here in topic.

With e-sven mod my index page is generating so slow, times are like 4-5sec which is not acceptable :(

With this topic mod my index is loading in 0.9-1.5sec, its pretty good but.... it has like 60 queries to my database. Isnt it too bad for my server?

For example my forum with e-sven (only) mod is generating 23 queries to mysql.

I just cant understand why 23 queries is much slower than 60 queries?

My forum has 500k posts, 1500 users and database is about 200mb (search keywords are removed, with keywords - 480mb) and on main page is listed 45 forums.

Any help is much appreciated.
xeite
Registered User
 
Posts: 3
Joined: Mon Feb 23, 2004 7:54 pm

Postby D¡cky » Sat Mar 26, 2005 1:32 am

This MOD as originally written is very slow. Use the query in this post,

http://www.phpbb.com/phpBB/viewtopic.ph ... 48#1417148

or this post,

http://www.phpbb.com/phpBB/viewtopic.ph ... 34#1482834

and you will see an increase in speed.

I don't know about e-sven's MOD.
Have you hugged someone today?
The phpBB.com Unofficial Support Team Forum
phpBB Installers Installations | Custom MODs | Conversions
User avatar
D¡cky
Support Team Member
Support Team Member
 
Posts: 7948
Joined: Tue Jan 25, 2005 8:38 pm
Location: New Hampshire, USA

Postby xeite » Sat Mar 26, 2005 10:47 am

This is e-sven's mod

Code: Select all
##############################################################
## Mod Title:   shows topic of last made post on index
## Mod Version: 1.4.0
## Author:      e-sven <sven@e-sven.net> http://www.e-sven.net
## Description: -adds lasts post topic to each forum on
##               the index page (based on read-access)
##      -word censorship is used
##      -topic title with more then 27 chars are cut off
##      -mouseover info displays the full title
##
## Installation Level:  easy
## Installation Time:   2-5 Minutes
## Files To Edit:       index.php
## Included Files:      index.php (pre-modded)
##############################################################
## History:
##         0.9 not released beta
##         1.0 first working release
##         1.1 optimized db access
##      1.2 made implementation easier
##          (only two replaces have to be made)
##         1.2a just a minor bug (thanks to Acid)
##         1.3 empty forums where not displayed correctly
##         1.4 optimized db-query
##############################################################
## Before Adding This MOD To Your Forum,
## You Should Back Up All Files Related To This MOD
##############################################################

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

#
#-----[ ACTION 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";
         break;
   }
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
   }

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

   if ( !($total_forums = count($forum_data)) )
   {
      message_die(GENERAL_MESSAGE, $lang['No_forums']);
   }

   //
   // Obtain a list of topic ids which contain


#
#-----[ REPLACE WITH ]----------------------------------------
#
      $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, t.topic_title, t.topic_last_post_id " .
         " FROM ((( " . FORUMS_TABLE . " f " .
         " LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )" .
         " LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id ) " .
         " LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = p.post_id ) " .
         " ORDER BY f.cat_id, f.forum_order";
      break;
   }
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
   }

   $forum_data = array();
   $topic_last_ary = array();
   $i=0;
   while( $row = $db->sql_fetchrow($result) )
   {
      if (!in_array($row['topic_last_post_id'], $topic_last_ary) || $row['topic_last_post_id']==0) {
         $topic_last_ary[i]=$row['topic_last_post_id'];
         $i++;
         $forum_data[] = $row;
      }
   }
   unset($topic_last_ary);
   if ( !($total_forums = count($forum_data)) )
   {
      message_die(GENERAL_MESSAGE, $lang['No_forums']);
   }
   
   //
   // Filter topic_title not allowed to read
   //
   if ( !($userdata['user_level'] == ADMIN && $userdata['session_logged_in']) ) {
      $auth_read_all = array();
      $auth_read_all=auth(AUTH_READ, AUTH_LIST_ALL, $userdata, $forum_data);
      $auth_data = '';
      for($i=0; $i<count($forum_data); $i++)
      {
         if (!$auth_read_all[$forum_data[$i]['forum_id']]['auth_read']) {
            $forum_data[$i]['topic_title']='';
         }
      }
   }

   //
   // Define censored word matches
   //
   $orig_word = array();
   $replacement_word = array();
   obtain_word_list($orig_word, $replacement_word);

   //
   // Obtain a list of topic ids which contain


#
#-----[ ACTION Find ]-----------------------------------------
#
   if ( $forum_data[$j]['forum_last_post_id'] )
   {
   ...
   }


#
#-----[ ACTION Replace With ]---------------------------------
#
   if ( $forum_data[$j]['forum_last_post_id'] )
   {
      $topic_title = $forum_data[$j]['topic_title'];
      $topic_title2 = $forum_data[$j]['topic_title'];
      
      //
      // Censor topic title
      //
      if ( count($orig_word) )
      {
         $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
         $topic_title2 = preg_replace($orig_word, $replacement_word, $topic_title2);
      }
                              
      if (strlen($topic_title)>27) {
         $topic_title = substr($topic_title,0,24) . '...';
      }

      $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'] . '" title="' . $topic_title2 . '">' . $topic_title . '</a><br>';
      $last_post .= $last_post_time . '&nbsp;<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><br>' . $lang['by'] . '&nbsp;';
      $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&amp;" . POST_USERS_URL . '='  . $forum_data[$j]['user_id']) . '">' . $forum_data[$j]['username'] . '</a> ';
   }

#
#-----[ SAVE/CLOSE ALL FILES ]----------------------------------
#


And Yes I tried the new queries from this topic (without them this Last topic mod wasnt working for me - blank screen).

Could you try how e-sven mod is working for you? as I said it has 1/3 queries less for me but is 5 times slower than this topic mod.
xeite
Registered User
 
Posts: 3
Joined: Mon Feb 23, 2004 7:54 pm

Postby D¡cky » Sun Mar 27, 2005 6:49 pm

xeite wrote:Could you try how e-sven mod is working for you? as I said it has 1/3 queries less for me but is 5 times slower than this topic mod.

I tested and the results are:

SiliconHero w/y.m's query
4.825995 seconds | 27 queries

esven
5.274997 seconds | 14 queries

esven w/o word censor
3.433145 seconds | 14 queries

It seems that esven's word censor is what is taking most of the page generation time. Do we really need to censor the topic title?

To remove the censor, delete:
//
// Censor topic title
//
if ( count($orig_word) )
{
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
$topic_title2 = preg_replace($orig_word, $replacement_word, $topic_title2);
}
Have you hugged someone today?
The phpBB.com Unofficial Support Team Forum
phpBB Installers Installations | Custom MODs | Conversions
User avatar
D¡cky
Support Team Member
Support Team Member
 
Posts: 7948
Joined: Tue Jan 25, 2005 8:38 pm
Location: New Hampshire, USA

Re: [2.0.7] Last Topic MOD

Postby schmik07 » Sat Apr 02, 2005 8:29 pm

MOD Database Manager wrote:Classification: 55 Cosmetic/Styles

MOD Name: Last Topic MOD
Author: SiliconHero
MOD Description: Displays the title of and a link to the last topic replied to in a particular forum.

MOD Version: 1.0.0
Installation Level: Easy
Installation Time: ~ 1 Minute

Download File: last_topic.mod
File Size: 3405 Bytes

Security Score:


thank you so much. that is exactly what i have been looking for, and now i have it. i think it should be incorporated into all phpBB boards as standard, and then users of busy boards can see the most recent posts as soon as they view the index. thank you.

can it be added to viewforum.php as well?
schmik07
Registered User
 
Posts: 1
Joined: Sat Apr 02, 2005 8:27 pm

Re: [2.0.7] Last Topic MOD

Postby D¡cky » Sun Apr 03, 2005 4:53 pm

schmik07 wrote:can it be added to viewforum.php as well?

Why would you need it in viewforum.php? All the topics, poster and times are already listed.
Have you hugged someone today?
The phpBB.com Unofficial Support Team Forum
phpBB Installers Installations | Custom MODs | Conversions
User avatar
D¡cky
Support Team Member
Support Team Member
 
Posts: 7948
Joined: Tue Jan 25, 2005 8:38 pm
Location: New Hampshire, USA

Postby Gvalva » Tue Apr 19, 2005 8:45 am

Great Mod and easy to install, but I miss one feature I have seen on other forums:

jump after clicking on the topic title not to the last post in the topic, but to the first post since user'e last visit.
Gvalva
Registered User
 
Posts: 38
Joined: Tue May 25, 2004 4:21 am

PreviousNext

Return to [2.0.x] MOD Database Cleanup

Who is online

Users browsing this forum: No registered users and 2 guests