/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?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." second".(($d==1)?'':'s')." ago"; else { $d = floor($d / 60); if($d < 60) return $d." minute".(($d==1)?'':'s')." ago"; else { $d = floor($d / 60); if($d < 24) return $d." hour".(($d==1)?'':'s')." ago"; else { $d = floor($d / 24); if($d < 7) return $d." day".(($d==1)?'':'s')." ago"; else { $d = floor($d / 7); if($d < 4) return $d." week".(($d==1)?'':'s')." 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>