############################################################## ## 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.3.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. ## ## ## 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 ## ############################################################## ## 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 $imagepreview = ""; if(preg_match("#\[url=(.+)\]\[img:(.+)\](.+)\[/img(.+)\]\[/url\]#", $excerpt_post, $matches)){ $imagepreview = "\"$matches[1]\""; } else if(preg_match("#\[img:(.+)\](.+)\[/img:(.+)\]#", $excerpt_post, $matches)){ $imagepreview = "\"$matches[2]\""; } $char_limit = '500'; 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('#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,30)."..."; }else return $matches_s[0]; } # #-----[ OPEN ]------------------------------ # templates/subSilver/viewforum_body.tpl # #-----[ FIND ]----------------------------------- # {topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE}{topicrow.TOPIC_TITLE}
# # #-----[ IN-LINE FIND ]----------------------------------- # {topicrow.TOPIC_TYPE} # #-----[ IN-LINE AFTER, ADD ]------------------------------------------- # {topicrow.IMAGE_PREVIEW} # # #-----[ IN-LINE FIND ]----------------------------------- # {topicrow.TOPIC_TITLE}
# #-----[ IN-LINE AFTER, ADD ]------------------------------------------- #
{topicrow.EXCERPT_POST} ({topicrow.FIRST_POST_DATE}) # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # That's it! :)