1 (edited by Rewozz 2009-08-02 18:44)

Topic: .

.

Re: .

Its not a plugin its integration, a few people have been asking for this, if i get round to it i'll make an alternate punnews function smile

Re: .

Rewozz try this one, is this what you want?

<?php

define('PUN_ROOT', './');
define('PUN_ALLOW_INDEX', 1);

if (isset($_GET['action']))
    define('PUN_QUIET_VISIT', 1);

require PUN_ROOT.'include/common.php';

$page_title = pun_htmlspecialchars($pun_config['o_board_title']);

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

        // 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>';
        $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);
        // Display 80 karakter only (comment out next 8 lines to turn off)
        while ($cur_posts = $db->fetch_assoc($msg))
        {
            if (pun_strlen($cur_posts['message']) >= 80)
            {
                $cur_posts['message'] = substr($cur_posts['message'], 0, 79);
                $cur_posts['message'] .= '…';
            }
        }
        $num_comments = $db->result($db->query('SELECT COUNT(id)-1 AS num FROM '.$db->prefix.'posts WHERE topic_id='.$cur_topic['id']));
        $temp .= '<div class=box style="padding:5px; margin:4px;">'.$cur_post['message'].'</div>Posted by '.pun_htmlspecialchars($cur_post['poster']).' '.date('Y-m-d H:i', $cur_post['posted']).' | <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'">Comments ('.$num_comments.')</a>';
        $temp .= "</p>";
        if (isset($output)) {
            $output .= $temp;
        }
        else {
            $output = $temp;
        }
        ++$show_count;
    } // end of while
    $output .= "</div></div>";
    return $output;
}

//syntax: pun_news(forum id, number of news to display, truncate news);
echo pun_news(1, 5, 0);

require PUN_ROOT.'footer.php';

Re: .

hmm, why does that have

if (isset($_GET['action']))
    define('PUN_QUIET_VISIT', 1);

instead of just

define('PUN_QUIET_VISIT', 1);

Re: .

upss.. it was edit from my index.php which is has login box infront off it, if i'm not wrong the purpose off it is to affect the online list and the users last visit data. I notice if i don't put if (isset($_GET['action'])) then that page won't change the online list until we move to other page. But what I want is that page has affect before he/she moved tp other page. I'm newbie Connorhd, so if i've mistakes you're welcome to correct it wink

Re: .

whiteh0rs3 wrote:

upss.. it was edit from my index.php which is has login box infront off it, if i'm not wrong the purpose off it is to affect the online list and the users last visit data. I notice if i don't put if (isset($_GET['action'])) then that page won't change the online list until we move to other page. But what I want is that page has affect before he/she moved tp other page. I'm newbie Connorhd, so if i've mistakes you're welcome to correct it wink

but why
"if (isset($_GET['action']))"
index.php will never have an action will it?
that has nothing to do with the QUIET_VISIT if it is true then it won't update the list which is the idea, otherwise if you just visit the index but not the forum then your topics will be marked as read (a really bad idea imo)

Re: .

on my case yes it has an action and yes it update the list, sorry but i'm too lazy and too tired to describe it right now. Visit my site maybe it will self explain, btw thanks for the critics... smile

Re: .

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, 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());
    $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'].'" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject_truncated).'</a>';
        $newsfooter = '<br /><em>Posted by '.$cur_topic['poster'].' | '.format_time($cur_topic['posted']).' | Comments(<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'].'</a>)</em>';
        // Group posts by date    
        $thisdate = date('l, d F Y', $cur_topic['posted']);
        if ($saveddate)
        {
            $temp .= "</div></div>";
        }
        $temp .= '<div class="block"><h2><span>'.$newsheading.'</span></h2><div class="box"><div class="inbox">';
        $saveddate = $thisdate;
        $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'] . "<p>";
        $temp .= $newsfooter;
        $temp .= "</p></div>";
        if (isset($output)) {
            $output .= $temp;
        }
        else {
            $output = $temp;
        }
        ++$show_count;
    } // end of while
    $output .= "</div></div>";
    return $output;
}

alternative pun_news

Re: .

you would need to give the miniportal its own tpl file and eit header.php