Sorry about that. The forum description is misleading.
Post your mod release announcements in here.
You are not logged in. Please login or register.
PunBB Forums → Posts by bingiman
Sorry about that. The forum description is misleading.
Post your mod release announcements in here.
I was wondering if someone can help me out here. You know how the default pun forums look to the right when viewing the forums. Well normally it displays under Last Post the date and poster. I would like it to display the Subject name and poster instead. I also should mention that I am using the Sub-Forums mod so if someone can assist me with this that would be great. Below is my forum.php file:
<?php
/***********************************************************************
Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org)
This file is part of PunBB.
PunBB is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PunBB is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
************************************************************************/
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
if ($pun_user['g_read_board'] == '0')
message($lang_common['No view']);
// Load the index.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
################################################################################
########################### Sub Forum MOD (start) ##############################
################################################################################
$sfcount=0;
$sfdb = array($_parent_id_, $_topics_, $_posts_, $_last_post_id_, $_last_poster_, $_last_post_);
$forums_info = $db->query('SELECT num_topics, num_posts, parent_forum_id, last_post_id, last_poster, last_post, id, forum_name FROM '.$db->prefix.'forums ORDER BY disp_position') or error(implode($db->error(),''),__FILE__,__LINE__,$db->error());
while($current = $db->fetch_assoc($forums_info)) {
if ($current['parent_forum_id'] != 0)
{
$sfdb[$sfcount][0] = $current['parent_forum_id'];
$sfdb[$sfcount][1] = $current['num_topics'];
$sfdb[$sfcount][2] = $current['num_posts'];
$sfdb[$sfcount][3] = $current['last_post_id'];
$sfdb[$sfcount][4] = $current['last_poster'];
$sfdb[$sfcount][5] = $current['last_post'];
$sfdb[$sfcount][6] = $current['id'];
$sfdb[$sfcount][7] = $current['forum_name'];
$sfcount++;
}
}
################################################################################
########################### Sub Forum MOD ( end ) ##############################
################################################################################
// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.parent_forum_id FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND (f.parent_forum_id IS NULL OR f.parent_forum_id=0) ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
$cur_category = 0;
$cat_count = 0;
// stuff for toggling categories
$cat_ids = (isset($_COOKIE['collapseprefs']))? $_COOKIE['collapseprefs'].',': FALSE;
while ($cur_forum = $db->fetch_assoc($result))
{
$moderators = '';
if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?
{
if ($cur_category != 0)
echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n";
++$cat_count;
// Setting varibles for toggling categories
$div_box = strstr($cat_ids, $cat_count.',')? ' style="display:none"' : '';
$exp_img = (is_file('img/'.$pun_user['style'].'/exp_down.png')? 'img/'.$pun_user['style'].'/': 'img/') . (strpos($div_box,'none') ? 'exp_down.png' : 'exp_up.png');
?>
<div id="idx<?php echo $cat_count ?>" class="blocktable">
<h2>
<span class="conr"><a href="javascript:togglecategory(<?php echo $cat_count?>);"><img src="<?php echo $exp_img?>" alt="Collapse" id="img_<?php echo $cat_count?>" /></a></span>
<span><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></span>
</h2>
<div class="box" id="box_<?php echo $cat_count ?>"<?php echo $div_box?>>
<div class="inbox">
<table cellspacing="0">
<thead>
<tr>
<th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th>
<th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th>
<th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
</tr>
</thead>
<tbody>
<?php
$cur_category = $cur_forum['cid'];
}
$item_status = '';
$icon_text = $lang_common['Normal icon'];
$icon_type = 'icon';
// Are there new posts?
if (!$pun_user['is_guest'] && $cur_forum['last_post'] > $pun_user['last_visit'])
{
$item_status = 'inew';
$icon_text = $lang_common['New icon'];
$icon_type = 'icon inew';
}
// Is this a redirect forum?
if ($cur_forum['redirect_url'] != '')
{
$forum_field = '<h3><a href="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" title="'.$lang_index['Link to'].' '.pun_htmlspecialchars($cur_forum['redirect_url']).'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
$num_topics = $num_posts = ' ';
$item_status = 'iredirect';
$icon_text = $lang_common['Redirect icon'];
$icon_type = 'icon';
}
else
{
$forum_field = '<h3><a href="viewforum.php?id='.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
################################################################################
########################### Sub Forum MOD (start) ##############################
################################################################################
$n_t = 0;
$n_p = 0;
$l_pid = $cur_forum['last_post_id'];
$l_pr = $cur_forum['last_poster'];
$l_post = $cur_forum['last_post'];
for ($i = 0; $i < $sfcount; $i++)
{
if ($sfdb[$i][0] == $cur_forum['fid'])
{
$n_t = $n_t + $sfdb[$i][1];
$n_p = $n_p + $sfdb[$i][2];
if ($l_pid < $sfdb[$i][3])
{
$l_pid = $sfdb[$i][3];
$l_pr = $sfdb[$i][4];
$l_post = $sfdb[$i][5];
}
}
}
$num_topics = $n_t + $cur_forum['num_topics'];
$num_posts = $n_p + $cur_forum['num_posts'];
################################################################################
########################### Sub Forum MOD ( end ) ##############################
################################################################################
}
if ($cur_forum['forum_desc'] != '')
$forum_field .= "\n\t\t\t\t\t\t\t\t".$cur_forum['forum_desc'];
// If there is a last_post/last_poster.
if ($l_post != '')
$last_post = '<a href="viewtopic.php?pid='.$l_pid.'#p'.$l_pid.'">'.format_time($l_post).'</a><br /> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($l_pr).'</span>';
else
$last_post = ' ';
if ($cur_forum['moderators'] != '')
{
$mods_array = unserialize($cur_forum['moderators']);
$moderators = array();
while (list($mod_username, $mod_id) = @each($mods_array))
$moderators[] = '<a href="profile.php?id='.$mod_id.'"><span class="byuser">'.pun_htmlspecialchars($mod_username).'</span></a>';
$moderators = "\t\t\t\t\t\t\t\t".'<p><em>('.$lang_common['Moderated by'].'</em> '.implode(', ', $moderators).')</p>'."\n";
}
if (!empty($sfdb))
{
foreach ($sfdb as $sub_forums)
{
if ($cur_forum['fid'] == $sub_forums[0] && !$pun_user['is_guest'] && $sub_forums[5] > $pun_user['last_visit'])
{
$item_status = 'inew';
$icon_text = $lang_common['New icon'];
$icon_type = 'icon inew';
}
}
}
?>
<tr<?php if ($item_status != '') echo ' class="'.$item_status.'"'; ?>>
<td class="tcl">
<div class="intd">
<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo $icon_text ?></div></div>
<div class="tclcon">
<?php echo $forum_field."\n".$moderators ?>
<?php
$sub_forums_list = array();
if(!empty($sfdb)) {
foreach ($sfdb as $sub_forums) {
if($cur_forum['fid'] == $sub_forums[0]) {
$sub_forums_list[] = '<a class="sub_forum" href="viewforum.php?id='.$sub_forums[6].'"><span class="sub_forum">'.pun_htmlspecialchars($sub_forums[7]).'</span></a>';
}
}
// EDIT THIS FOR THE DISPLAY STYLE OF THE SUBFORUMS ON MAIN PAGE
if(!empty($sub_forums_list)) {
// Leave one $sub_forums_list commented out to use the other (between the ###..)
################################
// This is Single Line Wrap Style
$sub_forums_list = "\t\t\t\t\t\t\t\t".'<span class="sub_name">Sub Forums:</span> '.implode(', ', $sub_forums_list)."\n";
// This is List Style
//$sub_forums_list = "\n".'<b><em>Sub Forums:</em></b><br /> -- '.implode('<br /> -- ', $sub_forums_list)."\n";
################################
if ($cur_forum['forum_desc'] != NULL) {
echo "<br />";
}
// TO TURN OFF DISPLAY OF SUBFORUMS ON INDEX PAGE, COMMENT OUT THE FOLLOWING LINE
echo "$sub_forums_list";
}
}
?>
</div>
</div>
</td>
<td class="tc2"><?php echo $num_topics ?></td>
<td class="tc3"><?php echo $num_posts ?></td>
<td class="tcr"><?php echo $last_post ?></td>
</tr>
<?php
}
// Did we output any categories and forums?
if ($cur_category > 0)
echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n";
else
echo '<div id="idx0" class="block"><div class="box"><div class="inbox"><p>'.$lang_index['Empty board'].'</p></div></div></div>';
// Collect some statistics from the database
$result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error());
$stats['total_users'] = $db->result($result);
$result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
$stats['last_user'] = $db->fetch_assoc($result);
$result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);
?>
<div id="brdstats" class="block">
<h2><span><?php echo $lang_index['Board info'] ?></span></h2>
<div class="box">
<div class="inbox">
<dl class="conr">
<dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
<dd><?php echo $lang_index['No of users'].': <strong>'. $stats['total_users'] ?></strong></dd>
<dd><?php echo $lang_index['No of topics'].': <strong>'.$stats['total_topics'] ?></strong></dd>
<dd><?php echo $lang_index['No of posts'].': <strong>'.$stats['total_posts'] ?></strong></dd>
</dl>
<dl class="conl">
<dt><strong><?php echo $lang_index['User info'] ?></strong></dt>
<dd><?php echo $lang_index['Newest user'] ?>: <a href="profile.php?id=<?php echo $stats['last_user']['id'] ?>"><?php echo pun_htmlspecialchars($stats['last_user']['username']) ?></a></dd>
<?php
if ($pun_config['o_users_online'] == '1')
{
// Fetch users online info and generate strings for output
$num_guests = 0;
$users = array();
$result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());
while ($pun_user_online = $db->fetch_assoc($result))
{
if ($pun_user_online['user_id'] > 1)
$users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
else
++$num_guests;
}
$num_users = count($users);
echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";
if ($num_users > 0)
echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<dt><strong>'.$lang_index['Online'].': </strong></dt>'."\t\t\t\t".implode(',</dd> ', $users).'</dd>'."\n\t\t\t".'</dl>'."\n";
else
echo "\t\t\t".'<div class="clearer"></div>'."\n";
}
else
echo "\t\t".'</dl>'."\n\t\t\t".'<div class="clearer"></div>'."\n";
?>
</div>
</div>
</div>
<?php
$footer_style = 'index';
require PUN_ROOT.'footer.php';
Thanks in advance.
not yet, but it will be for sure.
Here is a sample of the boxover script used with the FP news mod.
Give me some feed back and let me know if I should include this as part or the final release.
@quaker. I would not call it final yet. Actually some users may not like all the extra flare added to it such as the title, total post, reg. date etc...They may find the main page topic over crowded. What may be a good idea is to have control over it in the user profile. This way members can turn on different options if they prefer. How's that for an idea? yes, yes..I have the ideas, I just cant code.
Also, you may not have noticed but that code has some info on it like them designed by Shedrock etc. This should be stripped from the script as well as the Welcome code at the very top.
yes, that is what I wanted. It works perfectly.
That is awesome. Is the line below:
$forumids = array(1,2);
$numposts = array(3,7); <--- this one. does this mean 3 post from forum #1 will be displayed and 7 posts will be displayed for forum #2?
Thanks again
That's ok, I actually like it like that. It makes sense to have it that way, so that the latest post will always appear at the top regardless of the forum.
Thank you so much for your help. I really, really appreciate all that you've done.
I did forget to ask you another favor in my previous post. Would it be hard to add a link replies so that when I click on it, it takes me to that reply nut if there are no replies it just shows the text Replies: with no URL.
Cheers!
Bingiman
It works great. The only thing is that it lists the posts in reverse. By that I mean Forum ID2 is listed before Forum ID1 even thought it is set as:
$forumids = array(1,2); Other than that it is great.
Edit: I guess because it is pulling the latest the order is correct? meaning that if my last post was in forum 2 then it will be displayed at top.
fair enoguh MattF. What I would like is this.
Display a set of forums in $newsdisply so that's we are clear on. I would then like it to display the latest topics from each forum. So if I set the $newsdisplay to display the 5 latest topics, then it should display the 5 topics from the a specific forum or I can choose 5 latest topics from 5 forums. Or another way would be to pull 5 latest topics from each forum but only display a set amount depending on the $newsdisplay setting, so if I had:
forum1, forum2 and forum3 then
forum1 displays 2 topics (latest)
forum2 displays 2 topics (latest)
forum3 displays 1 topic (latest)
Hope this makes more sense for you.
Or here is a scenario with a few settings in the index file which I would love to see. I am sure this must be very hard to code.
$newsdisplay = 1,2,3,4etc...;
$amtofpost = 2; // per forum
$totalpost = 5; // a total pull from all forums (if 5 forums are used, then it just defaults to the $newsdisplay max setting)
$disp_first_latest = $first // displays first post of each forum ubt the latest post, so if I started a new thread in that forum, it will display that post and not a reply to it. If set to $latest, the it displays the latest reply to that post.
whew! Hope you follow.
Well, considering that I am not a coder I really could not answer your complexed questions MattF. All I was trying to do was to get the index to display 5, 10, 15 posts. I don't know how many it will pull from each forum. Is it possible for it to pull a set amount from a variable like the $newsdisplay for example. So something like:
$newsid = array();
$newsid[] = '1, 2posts';
$newsid[] = '4, 3 posts';
etc...
Please do not crucify me. I really am lost with all this coding and to give specifics as to how it can all be done is way beyond me and this is why I am asking for the help. If it can't be done, then I accept that.
It is workable and does what it is intended to do. The problem that I am having is what I explained above. When I set a second forum it displays more than the set items on the page. I want it to be able to display 5 items regardless of the amount of forums being displayed on the main page. Hope you understand what I am trying to say.
...and what about my last post
hmm..Maybe MattF can look into that. I also found a problem. If I set for example 2 forums to display then the max setting which is (5) really has no effect. It displays way more than that. If however I remove the second forum, then it displays the correct amount of posts. Any solution for this issue and the one Connorhd mentioned.
Cheers!
Hi MattF,
below is my final script with all the changes etc. This one works perfectly and I figured out the append stuff just before I read this post (pats himself on the back )
Anyway, I also made some changes to the Read More area. If there was nothing more to read you still had the ||. I've eliminated that with a few changes. Here is it:
<?php
define('PUN_ROOT', './');
require_once PUN_ROOT.'include/common.php';
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require_once PUN_ROOT.'header.php';
require_once PUN_ROOT.'include/parser.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
$newsid = array(); //These are the forums the news is retrieved from.
$newsid[] = '1';
$newsid[] = '2';
$newsdisplay = '5'; //This is how many news articles are displayed.
$trunc_chars = '350'; //Amount of characters before truncation occurs.
if ($pun_config['o_index_message_show'] == 1)
{
?>
<div class="block">
<h2><span><?php echo pun_htmlspecialchars($pun_config['o_index_message_head']) ?></span></h2>
<div class="box">
<div class="inbox">
<?php echo $pun_config['o_index_message'] ?>
</div>
</div>
</div>
<?php
}
//----------------------------------------------------------------------//
function close_tags($string)
{
if (preg_match_all ('/<([a-z]+)[ >]/', $string, $start_tags))
{
$start_tags = $start_tags[1];
if (preg_match_all ('/<\/([a-z]+)>/', $string, $end_tags))
{
$complete_tags = array();
$end_tags = $end_tags[1];
foreach ($start_tags as $key => $val)
{
$posb = array_search ($val, $end_tags);
if (is_integer ($posb))
{
unset ($end_tags[$posb]);
}
else
{
$complete_tags[] = $val;
}
}
}
else
{
$complete_tags = $start_tags;
}
$complete_tags = array_reverse ($complete_tags);
for ($i = 0; $i < count ($complete_tags); $i++)
{
$string .= '</' . $complete_tags[$i] . '>';
}
}
// Removes irrelevant tags
$xhtml_tags = array ('</img>', '</hr>', '</br>');
$string = str_replace ($xhtml_tags, '', $string);
return $string;
}
//----------------------------------------------------------------------//
function truncate($string)
{
global $pun_config;
$trunc_chars = '350';
$length = $trunc_chars;
if (strlen ($string) <= $length)
{
return $string;
}
else if ($length > 0)
{$append = '...';
preg_match ('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$length.',}\b#U', $string, $matches);
$string = $matches[0];
$string = close_tags (preg_replace ('#\s*<[^>]+>?\s*$#', '', $string).$append);
return $string;
}
}
//----------------------------------------------------------------------//
foreach ($newsid as $forum)
{
$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id='.$forum.' AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$newsdisplay) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
while($cur_post = $db->fetch_assoc($result))
{
echo '<div class="block">';
if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
{
if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
{
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
}
else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
{
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
}
else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
{
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
}
}
else
{
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img alt="" src="img/noimage.gif" /></a>';
}
$news_message = parse_message($cur_post['message'], $cur_post['hide_smilies']);
if (pun_strlen($news_message) > $trunc_chars)
{
$news_message = truncate($news_message);
$read_more = ' <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'">Read More</a> |';
}
else
{
$read_more = '';
}
echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
<div class="box">
<div class="inbox">
<ul><li>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td style="border: 0px; padding: 0px 10px 7px 7px;"><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><?php echo $cur_post['subject']; ?></a></td>
</tr>
</table>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td align="left" style="white-space: nowrap; width: 8em; padding-left: 7px; padding-top: 6px; padding-bottom: 30px; border: 0px;" valign="top"><?php echo $user_avatar ?></td>
<td style="text-align: left; border: 0px; padding-top: 0px;" valign="top"><?php echo $news_message."\n" ?></td>
</tr>
</table>
<table class="news_footer" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%">
<?php
echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a> |'.$read_more.' Views: '.$cur_post['num_views'].' | Replies: '. $cur_post['num_replies'].'</span></span>'."\n";
if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST)
{
echo "\t\t\t\t\t\t\t".'<a href="viewtopic.php?id='.$cur_post['id'].'">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="float:right">'.'<a href="misc.php?report='.$cur_post['id'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['id'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['id'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['id'].'">'.$lang_topic['Quote'].'</a>'.'</span>'."\n\n\n\n";
}
?>
</td>
</tr>
</table>
</li></ul>
</div>
</div>
</div>
<?php
}
}
}
require PUN_ROOT.'footer.php';
?>
Thank you for ALL your hard work mate, and thanks to quaker and soonotes. You guys are awesome!
I see a slight problem in the script. If I set it to 350 characters and my text is below that it still displays the read more link.
looks and works great. How do I get the ... at the end of the truncated text as soonotes had in his own?
Don't mean to be a pain soonotes but is there a way for this to display more than one forum?
Here is the latest version of the completed script.
<?php
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
$newsid = '1'; //This is the forum the news is retrieved from
$newsdisplay = '5'; //This is how many news articles are displayed.
if ($pun_config['o_index_message_show'] == 1)
{
?>
<div class="block">
<h2><span><?php echo pun_htmlspecialchars($pun_config['o_index_message_head']) ?></span></h2>
<div class="box">
<div class="inbox">
<?php echo $pun_config['o_index_message'] ?>
</div>
</div>
</div>
<?php
}
$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id='.$newsid.' AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$newsdisplay) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
while($cur_post = $db->fetch_assoc($result))
{
$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
?>
<div class="block">
<?php
if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
{
if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
}
else
$user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img alt="" src="img/noimage.gif" /></a>';
echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
<div class="box">
<div class="inbox">
<ul><li>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td style="border: 0px; padding: 0px 10px 7px 7px;"><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><?php echo $cur_post['subject']; ?></a></td>
</tr>
</table>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td align="left" style="white-space: nowrap; width: 8em; padding-left: 7px; padding-top: 6px; padding-bottom: 30px; border: 0px;" valign="top"><?php echo $user_avatar ?></td>
<td style="text-align: left; border: 0px; padding-top: 0px;" valign="top"><?php echo $cur_post['message']."\n" ?></td>
</tr>
</table>
<table class="news_footer" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%">
<?php
echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a> | Views: '. $cur_post['num_views'].' | Replies: '. $cur_post['num_replies'].'</span></span>'."\n";
if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST)
echo "\t\t\t\t\t\t\t".'<a href="viewtopic.php?id='.$cur_post['id'].'">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="float:right">'.'<a href="misc.php?report='.$cur_post['id'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['id'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['id'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['id'].'">'.$lang_topic['Quote'].'</a>'.'</span>'."\n\n\n\n";
?>
</td>
</tr>
</table>
</li></ul>
</div>
</div>
</div>
<?
}
}
require PUN_ROOT.'footer.php';
All that is missing is the truncate function along with a link to "Read More" which would take you to the rest of the post.
Thanks in advance MattF.
I know that MattF. The problem is that I can't do it. I've tried along with quaker and we can't get it at all. We are not coders and we have absolutely no idea where to even begin. Can you add it to the script if I post it here for you. I would really, really appreciate it.
Well, no one seems to be able to get the truncate to work.
There is no image. You can change the colors if you look for the following in your Oxygen_cs.css file
DIV.icon
TR.iredirect DIV.icon
DIV.inew
I have asked this question in a previous thread and no one ever answered. Hopefully they will for you.
I could be wrong but I don't think this is possible. I've tried and had no success. Maybe someone will have a solution.
I tried that but had no success with that method.
PunBB Forums → Posts by bingiman
Powered by PunBB, supported by Informer Technologies, Inc.