1 (edited by iniara 2008-12-10 01:31)

Topic: Replace date with Topic

I want to replace the Last Post link on the index page for the name of the topic instead of the date format.

I read about it in this thread and the idea is great, but I would like for someone to explain this in detail. All I get is to use the Anycode extension, which I have installed. I just don't know what to do with it. What solution and hooks to add. A step by step might be beneficial to many users.

http://punbb.informer.com/forums/topic/ … ndex-page/

2

Re: Replace date with Topic

For you. Load Extension - http://punbb.informer.com/wiki/_media/p … ache=cache

Re: Replace date with Topic

big_smile Thank you so much! It works great and looks so much better now. Spasiba!

4

Re: Replace date with Topic

iniara wrote:

Spasiba!

Nezachto! :-)

5

Re: Replace date with Topic

I also must to thank you.. good job!

Re: Replace date with Topic

hi thanks for this extension hcs. its working great.
but I have a small problem... I have set the max  subject length to 75 characters (uni code) into the extern.php.
so when I use this extension its also shows 75 characters... and its not looking good sad
anyway to limit the max length without modifying the extern.php ? beacuse I need this length to display last post/topics on my html page.
thanks.

7 (edited by Reactor 2009-01-05 20:12)

Re: Replace date with Topic

Hi,
Thanks, it works for me, but it does not look good:
http://img65.imageshack.us/img65/5294/93950158ix6.th.jpg

Now my forums are much taller and the description with date and name of topic is little unclear.
The best way to fix it would be adding some width to this column.

Re: Replace date with Topic

or a 4-word limit?

Re: Replace date with Topic

Garciat wrote:

or a 4-word limit?

I have the same problem.
Could you modify this extension ?
as you said 4 word limit or a way to adjust the max_subject_length as in the extern.php ?
thanks.

10 (edited by User33 2009-01-05 00:59)

Re: Replace date with Topic

Replace line 33 on manifest.xml with:

$words = 4;

$forum_page['item_body']['info']['lastpost'] = str_replace(array(format_time($cur_forum['last_post']), '<cite>'),array(words(forum_htmlencode($cur_forum['subject']), $words), '<cite>'.format_time($cur_forum['last_post']).'</cite><cite>'),

and on a new line after line 32 add:

function words($string, $words)
{
    return implode(" ", array_slice(explode(' ', $string), 0, $words)) . '...';
}

Note: I haven't tested this.

11 (edited by MattF 2009-01-05 05:34)

Re: Replace date with Topic

Why not just put { overflow: hidden; } in the CSS for that column?

Re: Replace date with Topic

Don't works for me:

Fatal error: Cannot redeclare words() (previously declared in /var/www/pcmod/index.php(211) : eval()'d code:10) in /var/www/pcmod/index.php(211) : eval()'d code on line 13

I am not sure did I make it correctly, but I was not doing it as Garciat said, problem with lines.

Re: Replace date with Topic

Yea I have the same message. neutral

Why not just put { overflow: hidden; } in the CSS for that column?

I tried this everywhere I saw lastpost in the css.
but didnt work. could you tell which line exactly ?
thanks.

14

Re: Replace date with Topic

Right, the hook is probably in a loop...

Try this on line 31:

        <hook id="in_start"><![CDATA[
function words($string, $words)
{
    return implode(" ", array_slice(explode(' ', $string), 0, $words)) . '...';
}
        ]]></hook>

and delete

function words($string, $words)
{
    return implode(" ", array_slice(explode(' ', $string), 0, $words)) . '...';
}

in line 32

Re: Replace date with Topic

Nop, its not displaying anything about last post but I have an error message in eash forum :

Parse error: syntax error, unexpected ',' in /mnt/102/sda/4/a/site/forums/index.php(211) : eval()'d code on line 15

btw what about this extension ?
is it possible to make this extension to punBB ?

16

Re: Replace date with Topic

This works for me: http://snipplr.com/view/10940/topic-tit … ted-by-me/

17 (edited by SkyLine 2009-01-05 16:32)

Re: Replace date with Topic

Thanks a lot Garciat, its working fine now big_smile
I think I made a mistake while editing the file... roll

just one more question... cool
I want to remove the last post time and replace this with poster ID "by User". roll
I mean now I have 3 lines "subject", "day & time" , "user ID".
I wan to have only 2 lines, day and user ID on the same line insted of day and time.
Thanks.

18 (edited by Reactor 2009-01-05 16:52)

Re: Replace date with Topic

Yeah thanks it is working, but still in one place got little crash.
It should depend on chars not words.
Why new line is not with margin? I mean how can I fix it wink.

There is in CSS:

.brd .main-content .main-item li.info-lastpost strong {
     padding-left: 1em;
     font-style: normal;
     font-weight: normal;
    }

... but dunno how to change it. Padding and margin only seems to work for first line.

19

Re: Replace date with Topic

Ok, redownload the script from the same link.

Re: Replace date with Topic

wow ! now its awesome big_smile
you've added link to user profile, thats great wink
my forum looks pretty now smile
thank you very much Garciat, for you help wink

21

Re: Replace date with Topic

big_smile Enjoy!

22 (edited by SkyLine 2009-01-05 18:03)

Re: Replace date with Topic

Opps !!! I've just noticed that when I click on the last post subject links of each forums, it shows the same post roll
why??? roll

I mean it shows the first topic that I've posted when I created the forum roll

23

Re: Replace date with Topic

Lol, I was using the user's ID for the post ID -.- It's fixed!

Re: Replace date with Topic

Garciat wrote:

Lol, I was using the user's ID for the post ID -.- It's fixed!

haha big_smile , yeah its fine now smile
thanks again wink

25 (edited by Reactor 2009-01-05 20:00)

Re: Replace date with Topic

Thanks Garciat for extension.
Translated into Polish:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE extension SYSTEM "ext-1.0.dtd">
 
<!--
/**
 * @copyright topic_title_on_index Copyright (C) 2008 hcs
 * @copyright Copyright (C) 2008 PunBB, partially based on code copyright (C) 2008 FluxBB.org
 * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 * @package topic_title_on_index
 */
-->
 
<extension engine="1.0">
    <id>topic_title_on_index</id>
    <title>Topic title on forum index </title>
    <version>1.0.0 Beta</version>
    <description>Replace the Last Post link on the index page for the name of the topic instead of the date format.</description>
    <author>hcs</author>
 
    <minversion>1.3</minversion>
    <maxtestedon>1.3.2</maxtestedon>
 
    <hooks>
        <hook id="in_qr_get_cats_and_forums"><![CDATA[
$query['SELECT'] .=', t.subject, u.id as poster_id';
$query['JOINS'][] = array(
    'LEFT JOIN'    => 'topics AS t',
    'ON'        => 'f.last_post_id=t.last_post_id'
);
$query['JOINS'][] = array(
    'LEFT JOIN'    => 'users AS u',
    'ON'        => 'f.last_poster=u.username'
);
        ]]></hook>
 
        <hook id="in_start"><![CDATA[
function words($string, $words)
{
    return implode(" ", array_slice(explode(' ', $string), 0, $words)) . '...';
}
 
function relative_time($timestamp)
{
    $d = time() - $timestamp;
    if ($d < 60)
        return $d." sekund".(($d==1)?'e':'y')." temu";
    else
    {
        $d = floor($d / 60);
        if($d < 60)
            return $d." minut".(($d==1)?'e':'y')." temu";
        else
        {
            $d = floor($d / 60);
            if($d < 24)
                return $d." godzin".(($d==1)?'e':'y')." temu";
            else
            {
                $d = floor($d / 24);
                if($d < 7)
                    return $d." d".(($d==1)?'zień':'ni')." temu";
                else
                {
                    $d = floor($d / 7);
                    if($d < 4)
                        return $d." t".(($d==1)?'ydzień':'ygodnie')." temu";
                }//Week
            }//Day
        }//Hour
    }//Minute
}
 
$words = 4;
        ]]></hook>
 
        <hook id="in_normal_row_pre_display"><![CDATA[
if(strpos($forum_page['item_body']['info']['lastpost'], $lang_index['No post info']) === false && strpos($forum_page['item_body']['info']['lastpost'], $lang_common['Never']) === false)
    $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']).'">'.forum_htmlencode(words($cur_forum['subject'], $words)).'</a></strong> <cite>'.relative_time($cur_forum['last_post']).' '.sprintf($lang_index['Last poster'], '<a href="'.forum_link($forum_url['user'], $cur_forum['poster_id']).'">'.forum_htmlencode($cur_forum['last_poster']).'</a>').'</cite></li>';
        ]]></hook>
 
    </hooks>
 
</extension>

EDIT:  Sorry found some bugs in language. Polish is so hard and its immposible to do all correclty with this logic.

EDIT2:
Corrected, this time I hope it works correclty, Polish people check it please wink.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE extension SYSTEM "ext-1.0.dtd">
 
<!--
/**
 * @copyright topic_title_on_index Copyright (C) 2008 hcs
 * @copyright Copyright (C) 2008 PunBB, partially based on code copyright (C) 2008 FluxBB.org
 * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 * @package topic_title_on_index
 */
-->
 
<extension engine="1.0">
    <id>topic_title_on_index</id>
    <title>Topic title on forum index </title>
    <version>1.0.0 Beta</version>
    <description>Replace the Last Post link on the index page for the name of the topic instead of the date format.</description>
    <author>hcs</author>
 
    <minversion>1.3</minversion>
    <maxtestedon>1.3.2</maxtestedon>
 
    <hooks>
        <hook id="in_qr_get_cats_and_forums"><![CDATA[
$query['SELECT'] .=', t.subject, u.id as poster_id';
$query['JOINS'][] = array(
    'LEFT JOIN'    => 'topics AS t',
    'ON'        => 'f.last_post_id=t.last_post_id'
);
$query['JOINS'][] = array(
    'LEFT JOIN'    => 'users AS u',
    'ON'        => 'f.last_poster=u.username'
);
        ]]></hook>
 
        <hook id="in_start"><![CDATA[
function words($string, $words)
{
    return implode(" ", array_slice(explode(' ', $string), 0, $words)) . '...';
}
 
function relative_time($timestamp)
{
    $ago = ' temu';
    $d = time() - $timestamp;
    if ($d < 60)
    if ($d==1)
        return $d. " sekunde" .$ago;
    elseif (($d%10)>=2 && ($d%10)<=4 && ($d < 12 || $d > 14))
        return $d. " sekundy" .$ago;
    else
        return $d. " sekund" .$ago;       
    else
    {
        $d = floor($d / 60);
        if($d < 60)
                if ($d==1)
            return $d. " minute" .$ago;
        elseif (($d%10)>=2 && ($d%10)<=4 && ($d < 12 || $d > 14))
            return $d. " minuty" .$ago;
        else
            return $d. " minut" .$ago;     
        else
        {
            $d = floor($d / 60);
            if($d < 24)
                    if ($d==1)
                return $d. " godzine" .$ago;
            elseif (($d%10)>=2 && ($d%10)<=4 && ($d < 12 || $d > 14))
                return $d. " godziny" .$ago;
            else
                return $d. " godzin" .$ago; 
            else
            {
                $d = floor($d / 24);
                if($d < 7)
                    return $d." d".(($d==1)?'zień':'ni')." temu";
                else
                {
                    $d = floor($d / 7);
                    if($d < 4)
                       if ($d==1)
                return $d. " tydzień" .$ago;
            elseif (($d%10)>=2 && ($d%10)<=4 && ($d < 12 || $d > 14))
                return $d. " tygodnie" .$ago;
            else
                return $d. " tygodni" .$ago;
                }//Week
            }//Day
        }//Hour
    }//Minute
}
 
$words = 4;
        ]]></hook>
 
        <hook id="in_normal_row_pre_display"><![CDATA[
if(strpos($forum_page['item_body']['info']['lastpost'], $lang_index['No post info']) === false && strpos($forum_page['item_body']['info']['lastpost'], $lang_common['Never']) === false)
    $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']).'">'.forum_htmlencode(words($cur_forum['subject'], $words)).'</a></strong> <cite>'.relative_time($cur_forum['last_post']).' '.sprintf($lang_index['Last poster'], '<a href="'.forum_link($forum_url['user'], $cur_forum['poster_id']).'">'.forum_htmlencode($cur_forum['last_poster']).'</a>').'</cite></li>';
        ]]></hook>
 
    </hooks>
 
</extension>

Garciat like Polish language? ;P

I made for myself some helpfull notes:

1 sekunde
2-4 sekundy
5-21 sekund
22-24 sekundy
25-31 sekund
32-34 sekundy

1 minute
2-4 minuty
5-21 minut
22-24 minuty
25-31 minut
32-34 minuty

1 godzine
2-4 godziny
5-21 godzin
22-24 godziny
25-31 godzin
32-34 godziny

1 dzień
1+ dni

1 tydzień
2-4 tygodnie
5-21 tygodni
22-24 tygodnie
25-31 tygodni
32-34 tygodnie