1 (edited by Replika 2005-12-20 07:26)

Topic: [Mod] Topic Preview

##
##
##       Mod title: PunBB Topic Preview (with Mod Active Topic Lite)
##
##     Mod version: 1.1 Build 051220 
##  Works on PunBB: 1.2, 1.2.10
##          Author: Quoc Viet (aFeLiOn) e-mail: v[at]s[dot]vnn[dot]vn
##
##     Description: Show first 256 characters in first post or last post
##                  of topic on the Forum view and on Active Topic
##
##  Affected files: viewforum.php
##                  index.php (if using Mod Active Topic Lite)
##
##      Affects DB: No
##
##    Author notes: You can change Language, Config in file "mod_topicpreview.php".
##                  Mod Active Topic Lite is based on "Mod Active Topics" of Alex King.
##                  The Javascript is from Dynamic Drive DHTML code library.
##                  The Mod can't show last post on moved topic and the tooltip show
##                  behind combobox in IE.
##                  * Change from v1.0rc1:
##                    Add: Show last post
##                    Add: Include Mod Active Topic Lite
##                    Add: Config, Language
##                    Minor changes
##
##      Disclaimer: Please note that "mods" are not officially supported by
##                  PunBB. Installation of this modification is done at your
##                  own risk. Backup all applicable files before proceeding.
##
##
 
 
#
#---------[ 1. UPLOAD ]---------
#
include/mod_topicpreview.js to /include/
include/mod_topicpreview.php to /include/
#
#---------[ 2. OPEN ]---------
#
viewforum.php
#
#---------[ 3. FIND ]---------
#
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
#
#---------[ 4. AFTER, ADD ]---------
#
require PUN_ROOT.'include/mod_topicpreview.php'; // [1] Mod Topic Preview
#
#---------[ 5. FIND ]---------
#
// Fetch list of topics to display on this page
if ($pun_user['is_guest'] || $pun_config['o_show_dot'] == '0')
{
#
#---------[ 6. BEFORE, ADD ]---------
#
// [2-] mod Topic Preview
$sql = 'SELECT p.message AS fpost, p.id AS fpost_id, v.message AS lpost, v.id AS lpost_id, t.id, t.moved_to, t.last_post_id FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON (t.id=p.topic_id OR t.moved_to=p.topic_id) LEFT JOIN '.$db->prefix.'posts AS v ON (t.last_post_id=v.id AND t.moved_to IS NULL) WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
$result = $db->query($sql) or error('Unable to fetch first posts', __FILE__, __LINE__, $db->error());
$topic_preview = array();
while ($mod_tp = $db->fetch_assoc($result))
{
    switch ($mtp_show)
    {
        case 1: $mtp_fp = ($mod_tp['lpost']!='') ? $mtp_lang['lastpost'].'<br />'.mtp_trim($mod_tp['lpost']) : ''; break;
        case 2: $mtp_fp = $mtp_lang['firstpost'].'<br />'.mtp_trim($mod_tp['fpost']);
                if ($mod_tp['moved_to'] == 0 && $mod_tp['fpost_id'] != $mod_tp['lpost_id'])
                {
                    $mtp_fp .= '<br />'.$mtp_lang['lastpost'].'<br />'.mtp_trim($mod_tp['lpost']);
                }
                break;
        case 0:
        default: $mtp_fp = mtp_trim($mod_tp['fpost']); break;
    }
    if ($mod_tp['moved_to'] != 0 && $mtp_showmoved)
        $topic_preview[$mod_tp['moved_to']] = $mtp_fp;
    else
        $topic_preview[$mod_tp['id']] = $mtp_fp;
}
// [-2] mod Topic Preview

#
#---------[ 7. FIND ]---------
#
        if ($cur_topic['moved_to'] != 0)
            $subject = $lang_forum['Moved'].': <a href="viewtopic.php?id='.$cur_topic['moved_to'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
        else if ($cur_topic['closed'] == '0')
            $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
        else
        {
            $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
            $icon_text = $lang_common['Closed icon'];
            $item_status = 'iclosed';
        }
#
#---------[ 8. REPLACE WITH ]---------
#
        // [3-] mod Topic Preview
        if ($cur_topic['moved_to'] != 0)
            $subject = $lang_forum['Moved'].': <a href="viewtopic.php?id='.$cur_topic['moved_to'].'" onmouseover="ddrivetip(\''.$topic_preview[$cur_topic['moved_to']].'\')" onmouseout="hideddrivetip()">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
        else if ($cur_topic['closed'] == '0')
            $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'" onmouseover="ddrivetip(\''.$topic_preview[$cur_topic['id']].'\')" onmouseout="hideddrivetip()">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
        else
        {
            $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'" onmouseover="ddrivetip(\''.$topic_preview[$cur_topic['id']].'\')" onmouseout="hideddrivetip()">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
            $icon_text = $lang_common['Closed icon'];
            $item_status = 'iclosed';
        }
        // [-3] mod Topic Preview
#
#---------[ 9. ONLY IF USING MOD ACTIVE TOPIC LITE ]---------
#
    #
    #---------[ 9a. OPEN ]---------
    #
    index.php
    #
    #---------[ 9b. FIND ]---------
    #
    define('PUN_ALLOW_INDEX', 1);
    require PUN_ROOT.'header.php';
    
    #
    #---------[ 9c. AFTER, ADD ]---------
    #
    require PUN_ROOT.'include/mod_topicpreview.php';
    mtp_showactopic();    // Mod Topic Preview with Active Topic Lite
#
#---------[ 10. SAVE/UPLOAD ]---------
#

Preview:
http://img205.imageshack.us/img205/606/punbbmodtopicpreview3gl.gif
http://img517.imageshack.us/img517/347/punbbmtp026td.gif
Download here

:Maxthon:FireFox:MirandaIM:ThunderBird:SmartFTP:FreePOPs:HTTrack:uTorrent:
:FlashGet:TCPOptimizer:SPECTralSMTPServer:UniExtract:PSPad:uStart:Everest:
:TotalCommander:ProcessExplorer:DriveMan:Regshot:Restoration:UPX:KolorGenerator:
:OpenOffice:AutoHotkey:IrfanView:Winamp:FSCapture:CDex:PNGOptimizer:spam:

Re: [Mod] Topic Preview

Cool. That's a rather unconventional way of doing it. All the other mods I've seen use the title attribute of the a tag, but this causes problems in Firefox because it doesn't quite like linebreaks in the title attribute.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: [Mod] Topic Preview

Not bad at all. smile No doubt it's going to create a lot of excess output. After which point do you have the post truncated?

I don't HAVE a signature, ok?

Re: [Mod] Topic Preview

big_smile I'm only amateur (and bad English sad )

After which point do you have the post truncated?

if (strlen($cur_tp)>256)

Punbb not have column "first post" in the database. I tried with the topic query (at "// Without the dot" & "// With the dot") but there a problem with "Moved topic". So I get first post outside.
I think there are some bugs in my project.

Apologies for my bad english again.

:Maxthon:FireFox:MirandaIM:ThunderBird:SmartFTP:FreePOPs:HTTrack:uTorrent:
:FlashGet:TCPOptimizer:SPECTralSMTPServer:UniExtract:PSPad:uStart:Everest:
:TotalCommander:ProcessExplorer:DriveMan:Regshot:Restoration:UPX:KolorGenerator:
:OpenOffice:AutoHotkey:IrfanView:Winamp:FSCapture:CDex:PNGOptimizer:spam:

Re: [Mod] Topic Preview

nice mod but i have a problem with ie explorer with the combobox of footer.

El Mejor Lugar de la Red - Corporación Azakur4

Re: [Mod] Topic Preview

Release Version 1.1
Changes:
  Add: Show last post
  Add: Include Mod Active Topic Lite
  Add: Config, Language
  Minor changes

nice mod but i have a problem with ie explorer with the combobox of footer.

ok, but don't know why big_smile

:Maxthon:FireFox:MirandaIM:ThunderBird:SmartFTP:FreePOPs:HTTrack:uTorrent:
:FlashGet:TCPOptimizer:SPECTralSMTPServer:UniExtract:PSPad:uStart:Everest:
:TotalCommander:ProcessExplorer:DriveMan:Regshot:Restoration:UPX:KolorGenerator:
:OpenOffice:AutoHotkey:IrfanView:Winamp:FSCapture:CDex:PNGOptimizer:spam:

Re: [Mod] Topic Preview

Hi,
nice mod....

could i have this as option in the profile?
Perhaps, if anybody dont like this mod, he could use the old style...

Greetings
Michaela

8

Re: [Mod] Topic Preview

The other way of doing it is to use an absolutely positioned span inside the <a> tag which means you can dispense with the javascript though positioning the output can be a bit tricky.
http://www.meyerweb.com/eric/css/edge/popups/demo.html

Re: [Mod] Topic Preview

http://i7.tinypic.com/27xfehv.jpg

How do I remove the statistics -- replies, views and time (like those in the image above) from the active topics box?

Re: [Mod] Topic Preview

in mod_topicpreview.php

Find:

echo '<font color="#FF9900"><strong>›</strong></font> '.$last_post.' <span class="byuser">» '.pun_htmlspecialchars($cur_topic['last_poster']).' » '.$lang_common['Replies'].': '.$cur_topic['num_replies'].' » '.$lang_forum['Views'].': '.$cur_topic['num_views'].' » '.format_time($cur_topic['last_post']).'</span>';

Replace:

echo '<font color="#FF9900"><strong>›</strong></font> '.$last_post.' <span class="byuser">» '.pun_htmlspecialchars($cur_topic['last_poster']).'</span>';
:Maxthon:FireFox:MirandaIM:ThunderBird:SmartFTP:FreePOPs:HTTrack:uTorrent:
:FlashGet:TCPOptimizer:SPECTralSMTPServer:UniExtract:PSPad:uStart:Everest:
:TotalCommander:ProcessExplorer:DriveMan:Regshot:Restoration:UPX:KolorGenerator:
:OpenOffice:AutoHotkey:IrfanView:Winamp:FSCapture:CDex:PNGOptimizer:spam:

11

Re: [Mod] Topic Preview

The font tag is not valid xhtml 1.0 strict and is generally deprecated. You need to style the element via the stylesheet.

12

Re: [Mod] Topic Preview

Thanks

13

Re: [Mod] Topic Preview

On our forum, causing high (long respons query). Especially for Forum had large/many topics sad
And no-success result.. I restore my viewforum.php backup file.

But, if forum had few topics (eg. below 10), this mod works nice smile

browser : Opera

PunBB, Simplicity has been easier than before
Smart is Simple. Fast is Smart. Think Fast, You'll be Smart..

regards,
PunBB & SMF Fans

14 (edited by FruitCake 2007-03-16 13:24)

Re: [Mod] Topic Preview

hi

pls help me

I'm use rewrite url mod

step8.  REPLACE WITH

// [3-] mod Topic Preview
        if ($cur_topic['moved_to'] != 0)
            $subject = $lang_forum['Moved'].': <a href="viewtopic.php?id='.$cur_topic['moved_to'].'" onmouseover="ddrivetip(\''.$topic_preview[$cur_topic['moved_to']].'\')" onmouseout="hideddrivetip()">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
        else if ($cur_topic['closed'] == '0')
            $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'" onmouseover="ddrivetip(\''.$topic_preview[$cur_topic['id']].'\')" onmouseout="hideddrivetip()">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
        else
        {
            $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'" onmouseover="ddrivetip(\''.$topic_preview[$cur_topic['id']].'\')" onmouseout="hideddrivetip()">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
            $icon_text = $lang_common['Closed icon'];
            $item_status = 'iclosed';
        }
        // [-3] mod Topic Preview

but my file code have a rewrite  mod

this code

        if ($cur_topic['moved_to'] != 0)
            $subject = $lang_forum['Moved'].': <a href="'.makeurl("t", $cur_topic['moved_to'], $cur_topic['subject']).'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';

        else if ($cur_topic['closed'] == '0')
            $subject = '<a href="'.makeurl("t", $cur_topic['id'], $cur_topic['subject']).'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';

        else
        {
            $subject = '<a href="'.makeurl("t", $cur_topic['id'], $cur_topic['subject']).'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';

            $icon_text = $lang_common['Closed icon'];
            $item_status = 'iclosed';
        }

how can I edit code in step8 to use with rewrite  mod

sorry my bad english