1 (edited by fakhrudin 2009-04-07 13:02)

Topic: [Modification] Show Post Name Under "Last Post" In Index

First i was looking for this myself now Slavok posted a solution so ill put a modified version of his and mine in this post


Go to 68 line of index.php. And replace array "$query" with this:

$query = array(
    'SELECT'    => 'c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, t.subject',
    'FROM'        => 'categories AS c',
    'JOINS'        => array(
        array(
            'INNER JOIN'    => 'forums AS f',
            'ON'            => 'c.id=f.cat_id'
        ),
        array(
            'LEFT JOIN'     => 'topics AS t',
            'ON'            => 't.last_post_id=f.last_post_id'
        ),
        array(
            'LEFT JOIN'     => 'forum_perms AS fp',
            'ON'            => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
        )
    ),
    'WHERE'        => 'fp.read_forum IS NULL OR fp.read_forum=1',
    'ORDER BY'    => 'c.disp_position, c.id, f.disp_position'
);


Next

Find

    $forum_page['item_body']['info']['lastpost'] = '<li class="info-lastpost"><span class="label">'.$lang_index['Last post'].'</span> <strong><a href="'.forum_link($forum_url['post'], $cur_forum['last_post_id']).'">'.format_time($cur_forum['last_post']).'</a></strong> <cite>'.sprintf($lang_index['Last poster'], forum_htmlencode($cur_forum['last_poster'])).'</cite></li>';    

Change It Too

$forum_page['item_body']['info']['lastpost'] = '<li class="info-lastpost"><span class="label">'.$lang_index['Last post'].'</span> <strong><a href="'.forum_link($forum_url['post'], $cur_forum['last_post_id']).'">'.limit_characters(forum_htmlencode($cur_forum['subject'])).'</a></strong> <cite>'.sprintf($lang_index['Last poster'], forum_htmlencode($cur_forum['last_poster'])).'</cite><strong>'.format_time($cur_forum['last_post']).'</strong></li>';

Go To Functions.php in includes folder

Find

//
// Common helpers and forum's wrappers for PHP functions
//

After That Add

function limit_characters ($str)
{
        if ( strlen ( $str ) <= 30 )
        {
            return $str;
        }
        else {
            return substr ( $str, 0, 30 ) . '...';
        }
}

You Are Done. Punbb Rocks wink

Credit to Slavok &  Some to me tongue

Re: [Modification] Show Post Name Under "Last Post" In Index

  • Go to 68 line of index.php. And replace array "$query" with this:

$query = array(
    'SELECT'    => 'c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, t.subject',
    'FROM'        => 'categories AS c',
    'JOINS'        => array(
        array(
            'INNER JOIN'    => 'forums AS f',
            'ON'            => 'c.id=f.cat_id'
        ),
        array(
            'LEFT JOIN'     => 'topics AS t',
            'ON'            => 't.last_post_id=f.last_post_id'
        ),
        array(
            'LEFT JOIN'     => 'forum_perms AS fp',
            'ON'            => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
        )
    ),
    'WHERE'        => 'fp.read_forum IS NULL OR fp.read_forum=1',
    'ORDER BY'    => 'c.disp_position, c.id, f.disp_position'
);
  • Go to 211 line of index.php and replace it with this:

$forum_page['item_body']['info']['lastpost'] = '<li class="info-lastpost"><span class="label">'.$lang_index['Last post'].'</span> <strong><a href="'.forum_link($forum_url['post'], $cur_forum['last_post_id']).'">'.format_time($cur_forum['last_post']).'</a></strong> <cite>'.sprintf($lang_index['Last poster'], forum_htmlencode($cur_forum['last_poster'])).'</cite><strong>'.forum_htmlencode($cur_forum['subject']).'</strong></li>';

The last thing you can change is the style of a displayed subject.

Re: [Modification] Show Post Name Under "Last Post" In Index

Thanks a lot man

I Have Modified it little so that if the post name is big it is shortened automatically if any one wants

Go To Functions.php in includes folder

Add

function limit_characters ($str)
{
        if ( strlen ( $str ) <= 30 )
        {
            return $str;
        }
        else {
            return substr ( $str, 0, 30 ) . '...';
        }
}

After

//
// Common helpers and forum's wrappers for PHP functions
//

Then do the above first modification as Slavok said

and in the second change use this code instead

$forum_page['item_body']['info']['lastpost'] = '<li class="info-lastpost"><span class="label">'.$lang_index['Last post'].'</span> <strong><a href="'.forum_link($forum_url['post'], $cur_forum['last_post_id']).'">'.limit_characters(forum_htmlencode($cur_forum['subject'])).'</a></strong> <cite>'.sprintf($lang_index['Last poster'], forum_htmlencode($cur_forum['last_poster'])).'</cite><strong>'.format_time($cur_forum['last_post']).'</strong></li>';

4

Re: [Modification] Show Post Name Under "Last Post" In Index

Hey guys,

I just did the modifications on index.php and include/functions.php - The mod works so far, however, the topic name isn't displayed! How to fix this?

See the situation here: http://www.hmisland.com/community/index.php