##############################################################
## MOD Title: Post Exerpt
## MOD Author: Goxu < goxu@dowonders.net >
## MOD Description: Excerpts first posts and display them in the forum index.
## If there are images posted, the first one will be displayed in the forum index as thumbnail.
##
## MOD Version: 1.4.0
##
## Installation Level: (Easy)
## Installation Time: 5 Minutes
## Files To Edit: viewforum.php
## templates/subSilver/viewforum_body.tpl
## Included Files: (n/a)
##############################################################
## Author Notes: My First mod :) Great Thanks to dESiLVer, who created the Mouse Hover Last Post.
## This mod is just a little sister of that mod. Thanks to Mr. Ocean and hikkun for their support.
##
##
## In order to change the excerpt length, just edit the $char_limit = '380'; to whatever number you wish.
##############################################################
## MOD History:
##
## 2006-10-15 - Version 1.0.0
## 2006-10-18 - Version 1.1.0 :picture preview is avalable
## 2006-10-20 - Version 1.2.0 :trims long url and retrieve [img]-tagged images.
## 2006-10-22 - Version 1.3.0 :adds creation dates
## 2006-10-23 - Version 1.4.0 :fixed a imagepreview problem that does not extract the first image and other minor issues.
##
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------
#
viewforum.php
#
#-----[ FIND ]-----------------------------------
#
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
#
#-----[ AFTER, ADD ]-------------------------------------------
#
$sql = "SELECT post_text FROM " . POSTS_TEXT_TABLE . " WHERE post_id=" . $topic_rowset[$i]['topic_first_post_id'];
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$excerpt_post = $row['post_text'];
// insert image thumbnails
if (preg_match("#(?:\[url=(.+)\])?\[img:(.+)\](.+)\[/img:(.+)\]#", $excerpt_post, $matches)){
if ($matches[1]){
$imagepreview = "";
} else {
$imagepreview = "
";
}
}
$char_limit = '380';
if (strlen($excerpt_post) > $char_limit)
{
$excerpt_post=substr($excerpt_post, 0, $char_limit) . "....";
}
$excerpt_post = preg_replace("/\[.+\]/iU",'',$excerpt_post);
$excerpt_post = str_replace(array('"', '\''), array('"e;', '\\\''), $excerpt_post);
// trim long urls
$excerpt_post=preg_replace_callback('#\s*http://[^\s]+#i','trim_url',$excerpt_post);
// get the topic creation date
$first_post_date = create_date('d/M/y', $topic_rowset[$i]['topic_time'], $userdata['user_tz']);
#
#
#-----[ FIND ]-----------------------------------
#
'LAST_POST_TIME' => $last_post_time,
#
#-----[ AFTER, ADD ]-------------------------------------------
#
'EXCERPT_POST' => $excerpt_post,
'IMAGE_PREVIEW' => $imagepreview,
'FIRST_POST_DATE' => $first_post_date,
#
#-----[ FIND ]-----------------------------------
#
?>
#
#-----[ Before, ADD ]-------------------------------------------
#
function trim_url($matches_s){
if(strlen($matches_s[0])>50){
return substr($matches_s[0],0,40)."...";
}else return $matches_s[0];
}
#
#-----[ OPEN ]------------------------------
#
templates/subSilver/viewforum_body.tpl
#
#-----[ FIND ]-----------------------------------
#