############################################################## ## 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: 2.0.0 ## ## Installation Level: (Easy) ## Installation Time: 8 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. ## ## ## Please first se the configuration before actuary start using the MOD. ############################################################## ## 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. ## 2006-10-23 - Version 2.0.0 :BBcode, Smilies, and Row Cap etc. are avalable. ## ## ############################################################## ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD ############################################################## # #-----[ OPEN ]------------------------------ # viewforum.php # #-----[ FIND ]----------------------------------- # include($phpbb_root_path . 'common.'.$phpEx); # #-----[ AFTER, ADD ]------------------------------------------- # include($phpbb_root_path . 'includes/bbcode.'.$phpEx); # #-----[ FIND ]----------------------------------- # $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; # #-----[ AFTER, ADD ]------------------------------------------- # /* Post Excerpt - Begin */ // Configurations $char_limit = '380'; // The maximum charactor length. Set '0' to disable this entire mod. $row_limit = '4'; // The maximum row number. Set '0' to disable it. $img_height = 50; // The size of thumbnail. Set 0 to disable it $topictitle_fontsize = 10; // The default value is 10 $smilies_in_excerpt = FALSE; // Set TRUE/FALSE to enable/disable smilies (case sensitive) $bbcode_in_excerpt = FALSE; // Set TRUE/FALSE to enable/disable bbcode $autohyperlink = TRUE; // Set TRUE/FALSE to enable/disable bbcode $pe_nl2br = FALSE; // Set TRUE/FALSE to enable/disable newline creation if ($char_limit != '0'){ //reatreive the neccesary data from the database $sql = "SELECT p.enable_smilies, pt.post_text, pt.bbcode_uid FROM " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt WHERE pt.post_id=" . $topic_rowset[$i]['topic_first_post_id'] . " AND pt.post_id = p.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 ( $img_height != 0) { $imagepreview = ""; if (preg_match("#(?:\[url=(.+)\])?\[img:(.+)\](.+)\[/img:(.+)\]#", $excerpt_post, $matches)){ if ($matches[1]){ $imagepreview = "\"$matches[1]\""; } else { $imagepreview = "\"$matches[3]\""; } } } // limit max charactors, if (strlen($excerpt_post) > $char_limit) { $excerpt_post=substr($excerpt_post, 0, $char_limit) . "...."; } // limit max rows if ($row_limit != '0') { $excerpt_post_row = preg_split( '#\n#', $excerpt_post); if ( count($excerpt_post_row) > $row_limit ) { $assemble = ''; for ( $j=0; $row_limit-1>$j; $j++ ) { $assemble .= $excerpt_post_row[$j] . "\n"; } $assemble .= $excerpt_post_row[$row_limit-1]; $excerpt_post = $assemble . "...."; } } // delete images within [img:...] and [/img:...] $excerpt_post = preg_replace("#\[/?img:[a-z0-9]*\]#i", '', $excerpt_post); // if (!$bbcode_in_excerpt) { $excerpt_post = preg_replace("#\[/url\]#i", '', $excerpt_post); $excerpt_post = preg_replace("#\[/?url=(.?)*\]#i", '', $excerpt_post); } //// Parse $excerpt_post to html // Parse message for BBCode if reqd if ($bbcode_in_excerpt) { $bbcode_uid = $row['bbcode_uid']; if ($bbcode_uid != '') { $excerpt_post = ($board_config['allow_bbcode']) ? bbencode_second_pass($excerpt_post, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $excerpt_post); } } // Autohyperlink if ($autohyperlink) { $excerpt_post = make_clickable($excerpt_post); } // Parse smilies if ($smilies_in_excerpt) { if ( $board_config['allow_smilies'] ){ if ( $row['enable_smilies'] ) { $excerpt_post = smilies_pass($excerpt_post); } } } // Replace newlines if ($pe_nl2br) { $excerpt_post = str_replace("\n", "\n
\n", $excerpt_post); } // Trim long urls if (!$bbcode_in_excerpt) { $excerpt_post=preg_replace_callback('#\s*http://[^\s]+#i','trim_url',$excerpt_post); } else { $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']); // Replace naughty words $excerpt_post = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $excerpt_post . '<'), 1, -1)); } /* Post Excerpt - End */ # #-----[ FIND ]----------------------------------- # 'LAST_POST_TIME' => $last_post_time, # #-----[ AFTER, ADD ]------------------------------------------- # /* Post Excerpt - Begin */ 'EXCERPT_POST' => $excerpt_post, 'IMAGE_PREVIEW' => $imagepreview, 'TOPICTITLE_FONTSIZE' => 'style="font-size: ' . $topictitle_fontsize . 'pt;"', 'FIRST_POST_DATE' => $first_post_date, /* Post Excerpt - End */ # #-----[ FIND ]----------------------------------- # ?> # #-----[ Before, ADD ]------------------------------------------- # /* Post Excerpt - Begin */ function trim_url($matches_s){ if(strlen($matches_s[0])>50){ return substr($matches_s[0],0,40)."..."; }else return $matches_s[0]; } /* Post Excerpt - End */ # #-----[ 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 ]----------------------------------- #
# #-----[ IN-LINE AFTER, ADD ]------------------------------------------- #
{topicrow.EXCERPT_POST} ({topicrow.FIRST_POST_DATE}) # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # That's it! :)