1 (edited by Nephets7 2006-01-20 13:46)

Topic: Help needed with comments being displayed with the miniportal

http://sctech.dcdstudios.net/ my site/forum miniportal design is here, but, I cannot get a little description showing how many people commented on the entry in the forums.  What would I have to add to get that information to show up on the main index?  Everything else works perfect but I'd really like to have a display of comments show up!

Thanks.

-s

PS: This is in my index.php incase knowing it might help!

<?php

define('PUN_ROOT', './');
define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';

$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';

function pun_news($fid='', $show=15, $truncate=1)
{
    global $lang_common, $db, $pun_config, $db_prefix;
    $max_subject_length = 30;
    $show_max_topics = 50;
    $fid = intval($fid);
    $order_by = 't.posted';
    $forum_sql = '';
    // Was a forum ID supplied?
    if ( $fid ) $forum_sql = 'f.id='.$fid.' AND ';
    $show = intval($show);
    if ($show < 1 || $show > $show_max_topics)
    $show = 15;
    $saveddate="";
    // Fetch $show topics
    $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name FROM '.$db_prefix.'topics AS t INNER JOIN '.$db_prefix.'forums AS f ON t.forum_id=f.id WHERE f.id='.$fid.' AND t.moved_to IS NULL ORDER BY '.$order_by.' DESC') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
    $show_count = 0;
    if ( !$db->num_rows($result) ) return $output;
    while ( ($show_count < $show) && ($cur_topic = $db->fetch_assoc($result)) ) {
        $temp = '';
        if ($pun_config['o_censoring'] == '1')
            $cur_topic['subject'] = censor_words($cur_topic['subject']);
        if (pun_strlen($cur_topic['subject']) > $max_subject_length)
            $subject_truncated = trim(substr($cur_topic['subject'], 0, ($max_subject_length-5))).' ...';
        else
            $subject_truncated = $cur_topic['subject'];
        $newsheading = '<a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject_truncated).'</a> - <em>Posted by '.$cur_topic['poster'].' at '.date('h:i A', $cur_topic['posted']).'</em><br>';
        // Group posts by date   
        $thisdate = date('l, d F Y', $cur_topic['posted']);
        if ($thisdate != $saveddate)
        {
            if ($saveddate)
            {
                $temp .= "</div></div>";
            }
            $temp .= '<div class="block"><h2><span>'.$thisdate.'</span></h2><div class="box"><div class="inbox"><p>';
            $saveddate = $thisdate;
        }
        else {
            $temp .= '<div class="inbox"><p>';
        }
        $temp .= $newsheading.'</p><p>';
        $id = $cur_topic['id'];
        $msg = $db->query('SELECT id, poster, poster_id, poster_ip, poster_email, message, posted, edited, edited_by FROM '.$db_prefix.'posts WHERE topic_id='.$id.' LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
            if ( !$db->num_rows($msg) ) continue;
        $cur_post = $db->fetch_assoc($msg);
        // Display first paragraph only (comment out next four lines to turn off)
        if ($truncate == 1)
        {
        $paragraph = preg_split("/\s*\n+/", $cur_post['message']);
            if (isset($paragraph[1])) {
                $cur_post['message'] = $paragraph[0] . "...";
            }
        }
        $cur_post['message'] = parse_message($cur_post['message'], 0);
        $temp .= $cur_post['message'];
        $temp .= "</p></div>";
        if (isset($output)) {
            $output .= $temp;
        }
        else {
            $output = $temp;
        }
        ++$show_count;
    } // end of while
    $output .= "</div></div>";
    return $output;
}
?>
       
<?php
echo pun_news(26, 5, 0);

require PUN_ROOT.'footer.php';

Re: Help needed with comments being displayed with the miniportal

This with a bit of extra code I use in my forum...

http://www.marine-hunters.co.uk

Change this

$result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name FROM '.$db_prefix.'topics AS t INNER JOIN '.$db_prefix.'forums AS f ON t.forum_id=f.id WHERE f.id='.$fid.' AND t.moved_to IS NULL ORDER BY '.$order_by.' DESC') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

to this

$result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, t.num_replies, f.id AS fid, f.forum_name FROM '.$db_prefix.'topics AS t INNER JOIN '.$db_prefix.'forums AS f ON t.forum_id=f.id WHERE f.id='.$fid.' AND t.moved_to IS NULL ORDER BY '.$order_by.' DESC') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

Then if you use this

$cur_topic['num_replies']

it will give you the replies to that topic.

My line of code is

<a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.$cur_topic['num_replies'].' Comments...</a>

so that when you click on the comment link takes you straight to that topic.

Example here
http://www.marine-hunters.co.uk/img/temp/Test.jpg

Bit long winded so any problems let me know.

Re: Help needed with comments being displayed with the miniportal

Thanks!  Where exactly would I paste all of the lines of code you posted after the text I need to replace?  Where in index.php would it go?

Re: Help needed with comments being displayed with the miniportal

Nephets7 wrote:

Thanks!  Where exactly would I paste all of the lines of code you posted after the text I need to replace?  Where in index.php would it go?

This is the hard bit... because mine is set up differently... I have changed my index.php big time... because I wanted an overline at the bottom of each post and also the comments to the bottom right.

I can post you my pun_news function.... but it would no doubt work slightly different on yours to mine. sad

You on msn?

Re: Help needed with comments being displayed with the miniportal

yes.  spegg7@yahoo.com is my address

Re: Help needed with comments being displayed with the miniportal

Can anybody help?

Re: Help needed with comments being displayed with the miniportal

Nephets7 wrote:

yes.  spegg7@yahoo.com is my address

Have added you... Will try to help next time your on line mate..

Re: Help needed with comments being displayed with the miniportal

I would like to know about this to plaz.........

Re: Help needed with comments being displayed with the miniportal

Bump

Re: Help needed with comments being displayed with the miniportal

Bump...

Re: Help needed with comments being displayed with the miniportal

I have added you on MSN, STEVENBULLEN@ntlworld.com. Just speak to me when your on at the same time mate.