76

Re: PunBB Miniportal v1.2.x

Yeah, thanks for that post.  I was jumping in today to ask how to curb that very problem.

And hooray for the mini-portal!  It was just what I needed for the site I'm toying around with.  Thanks again, Connorhd!

77

Re: PunBB Miniportal v1.2.x

Connorhd wrote:

#1: In one of the category i made a forum called news section wich is the one i am linking to my miniportal how can i make it so only the first post of each thread is shown in the miniportal and not the reply.

it only displays the first post anyway

well it seem that it does now it suddently started to display the reply of user

Re: PunBB Miniportal v1.2.x

Using XuMix's mod this one will work (I don't recomend this)

download AP_News_Generator and use it.

create news.php

<?php

// The forum from which we'll pull the news bits
$forum_id = 1;

// Number of news posts to include in the index
$num_posts_index = 10;

// Path to news item template
$template_path = PUN_ROOT.'plugins/AP_News_Generator/news.tpl';

// Directories in which plugin will save generated markup (must end with slash)
$output = '';
$output_dir_archive = PUN_ROOT.'plugins/AP_News_Generator/archive/';



    if (!isset($archive))
    {
    // Generate front page news
    $result = $db->query('SELECT id, subject FROM '.$db->prefix.'topics WHERE forum_id='.$forum_id.' ORDER BY sticky DESC, posted DESC LIMIT 0, '.$num_posts_index) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message('There are no topics to generate news based on in forum with ID = '.$forum_id.'.');

    

    $news_tpl = file_get_contents($template_path) or error('Unable to open new item template '.$template_path.'. Make sure $template_path is correct', __FILE__, __LINE__);

/*    $fh = @fopen($output_dir_latest.'news.html', 'wb');
    if (!$fh)
        error('Unable to write news to '.$output_dir_latest.'news.html. Please make sure PHP has write access to the directory '.$output_dir_latest, __FILE__, __LINE__);
*/
    while ($cur_topic = $db->fetch_assoc($result))
    {
        $result2 = $db->query('SELECT posted, poster, message, hide_smilies FROM '.$db->prefix.'posts WHERE topic_id='.$cur_topic['id'].' ORDER BY posted ASC LIMIT 1') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
        $cur_post = $db->fetch_assoc($result2);
        $num_comments = $db->result($db->query('SELECT COUNT(id)-1 AS num FROM '.$db->prefix.'posts WHERE topic_id='.$cur_topic['id']));
        
        $search = array('<news_subject>', '<news_posted>', '<news_poster>', '<news_message>', '<news_comments>');
        $replace = array(pun_htmlspecialchars($cur_topic['subject']), date('Y-m-d H:i', $cur_post['posted']), pun_htmlspecialchars($cur_post['poster']), parse_message($cur_post['message'], $cur_post['hide_smilies']), '<a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'">Comments ('.$num_comments.')</a>');

        $output .=  str_replace($search, $replace, $news_tpl);
    }
    
    $output .= '';
    
    //display news
    echo $output;
    
}    
 else 
    {    
// Generate monthly archives
    $year_end = intval(date('Y'));
    $month_end = intval(date('n'));

    $year_start = ($month_end != 1) ? $year_end : $year_end-1;
    $month_start = ($month_end != 1) ? $month_end-1 : 12;

    // How far back should we go?
    $result = $db->query('SELECT MIN(posted) FROM '.$db->prefix.'topics WHERE forum_id='.$forum_id.'') or error('Unable to fetch earliest topic', __FILE__, __LINE__, $db->error());
    $history_limit = $db->result($result);

    $year_limit = intval(date('Y', $history_limit));
    $month_limit = intval(date('n', $history_limit));

    while ($year_end > $year_limit || $month_end > $month_limit)
    {
        $result = $db->query('SELECT id, subject FROM '.$db->prefix.'topics WHERE forum_id='.$forum_id.' AND posted>=UNIX_TIMESTAMP(\''.$year_start.'-'.$month_start.'-01\') AND posted<UNIX_TIMESTAMP(\''.$year_end.'-'.$month_end.'-01\') ORDER BY posted DESC') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
        if ($db->num_rows($result))
        {
            $news_tpl = file_get_contents($template_path) or error('Unable to open new item template '.$template_path.'. Make sure $template_path is correct', __FILE__, __LINE__);

            $fh = @fopen($output_dir_archive.$year_end.'-'.($month_start > 9 ? $month_start : '0'.$month_start).'.html', 'wb');
            if (!$fh)
                error('Unable to write news archive to '.$output_dir_archive.$year_end.'-'.($month_end > 9 ? $month_end : '0'.$month_end).'.html Please make sure PHP has write access to the directory '.$output_dir_archive, __FILE__, __LINE__);

            while ($cur_topic = $db->fetch_assoc($result))
            {
                $result2 = $db->query('SELECT posted, poster, message, hide_smilies FROM '.$db->prefix.'posts WHERE topic_id='.$cur_topic['id'].' ORDER BY posted ASC LIMIT 1') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
                $cur_post = $db->fetch_assoc($result2);
                $num_comments = $db->result($db->query('SELECT COUNT(id)-1 AS num FROM '.$db->prefix.'posts WHERE topic_id='.$cur_topic['id']));
                
                $search = array('<news_subject>', '<news_posted>', '<news_poster>', '<news_message>', '<news_comments>');
                $replace = array(pun_htmlspecialchars($cur_topic['subject']), date('Y-m-d H:i', $cur_post['posted']), pun_htmlspecialchars($cur_post['poster']), parse_message($cur_post['message'], $cur_post['hide_smilies']), '<a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'">Comments ('.$num_comments.')</a>');

                fwrite($fh, str_replace($search, $replace, $news_tpl));
            }

            fclose($fh);
        }

        $year_end = $year_start;
        $month_end = $month_start;
        $year_start = ($month_end != 1) ? $year_end : $year_end-1;
        $month_start = ($month_end != 1) ? $month_end-1 : 12;
    }

//Archive display
        

    $dir = "./archive/";
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
       $file_arr = array(); $f = 0;
       
        while (false !== ($file = readdir($dh))) {
            if ($file != "." && $file != ".." && $file != "index.php" && $file[0] != ".") {
                 $file_arr[$f++] = $file;
             }
        }
        closedir($dh);
    }
      sort( $file_arr ); reset( $file_arr );
    for( $i=1; $i < count( $file_arr ) +1 ; $i++ ) {
        echo "<a href=\"'.PUN_ROOT.'news.php?month='.$i.'&archive=true\">".str_replace('.html', '', $file_arr[$i-1])."</a><br>";    
         }
        
}

    if(isset($_GET['month']) && (file_exists('./archive/'.$year_end.'-0'.$month.'.html') || file_exists('./archive/'.$year_end.'-0'.$month.'.html') ) )
    {
        if($month < 10)        
        include './archive/'.$year_end.'-0'.$month.'.html';
        else 
        include './archive/'.$year_end.'-'.$month.'.html';
    }
    else if(isset($_GET['month']) && (!file_exists('./archive/'.$year_end.'-0'.$month.'.html') || !file_exists('./archive/'.$year_end.'-0'.$month.'.html') ) )
    message($lang_common['Bad request']);
    
}


?>

create your index.php to be something like this.

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

        <div class="block">
            <h2><span>Welcome</span></h2>
            <div class="box">
                <div class="inbox">
                    <p>Welcome box</a>
                    </p>
                </div>
            </div>
        </div>

<?php
//Gets the news :)
require PUN_ROOT.'news.php';

//just so I know its my footer.
require PUN_ROOT.'footer.php';

Not the best way of doing things but it looks professional and it's something to use while Connorhd fixes his page so you won't look ignorant

Re: PunBB Miniportal v1.2.x

Ataxy: huh? it doesn't display replies for me, surely if it just suddenly started its something you have done?

shinko_metsuo: whats wrong with my page?

Re: PunBB Miniportal v1.2.x

When someone post under a post you made it takes the other post and not the main one. (this is hard to explain)

say I posted a new topic to be shown on the news page

My post wrote:

Ipsum

then someone else comes along and post under

someone else wrote:

Lorem

someone else's post will show on the news page instead of mine

Re: PunBB Miniportal v1.2.x

thats very odd, it doesn't happen for me lol i'll look into it

82 (edited by Ataxy 2005-05-25 19:40)

Re: PunBB Miniportal v1.2.x

Connorhd wrote:

Ataxy: huh? it doesn't display replies for me, surely if it just suddenly started its something you have done?

shinko_metsuo: whats wrong with my page?

actualy no all i did was recently change the amount of news been shown from 5 to 12 as news where going away to fast also the weird part is that it stopped showing the reply after the second reply

Re: PunBB Miniportal v1.2.x

ok seems to be something strange i'll look at it when i get a chance

Re: PunBB Miniportal v1.2.x

shinko_metsuo: try changing

$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());

to

$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.' ORDER BY id LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

Ataxy: if its displaying the reply as well can you paste your index.php here? if its just display the rply and not the orignal do the fix i just said, and see if it works, i don't get this problem so its hard for me to fix

Re: PunBB Miniportal v1.2.x

I think that did the trick

thanks connorhd

86

Re: PunBB Miniportal v1.2.x

oh theis seem to have done the trick connorhd

for your info in case you want to see it here is my index.php

<?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 = 60;
    $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.' ORDER BY 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;
}
?>
        <div class="block">
            <h2><span>D-Vault Info</span></h2>
            <div class="box">
                <div class="inbox">
                    <p>
                     <center><b>Welcome to D-Vault and thank you for your participation in the different part of our com.
                     <br>
                     Bienvenue sur D-Vault et merci pour votre participation dans les differente partie de notre com.</b></center>
                    </p>
                </div>
            </div>
        </div>
<?php
echo pun_news(44, 12, 0);
 
require PUN_ROOT.'footer.php';

Re: PunBB Miniportal v1.2.x

ok thats great then smile

Re: PunBB Miniportal v1.2.x

Uh connorhd my man the nav bar still does not work in IE.

Re: PunBB Miniportal v1.2.x

doesn't work in IE? looks fine to me

90

Re: PunBB Miniportal v1.2.x

looks fine here to

Re: PunBB Miniportal v1.2.x

hmm well it was on one of the computers at the school and they never update those things. Maybe it was an older version.

92

Re: PunBB Miniportal v1.2.x

All,

  I figured I would let you guys know that I modded this a little bit and actually have it show the sidebar on the "Portal" page and left the sidebar off in the actual forums.  If anyone is interested, I can post the changes, it is actually very easy..

--
Robert
Administrator
NanoCubeForums.com

93

Re: PunBB Miniportal v1.2.x

rjg wrote:

All,

  I figured I would let you guys know that I modded this a little bit and actually have it show the sidebar on the "Portal" page and left the sidebar off in the actual forums.  If anyone is interested, I can post the changes, it is actually very easy..

yes, please do explain.

94

Re: PunBB Miniportal v1.2.x

Ataxy,

I started out by completing the first portion of the this mod found on the wiki page  http://nupusi.net/punbb:tutorials:miniportal which is to create the new index.php.

Then I moved onto the second portion which was to create the sidebar.

Here is what I did in the sidebar section:

1.  Instead of modifying main.tpl, I created a new file called main_index.tpl and put the content from the wiki in that file.

2.  I made the changes to header.php as described in the wiki.

3.  I copied header.php to header_main.php, then changed line 43
     FROM: $tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl');
     TO: $tpl_main = file_get_contents(PUN_ROOT.'include/template/main_index.tpl');

4.  In index.php, I changed line 9
     FROM: require PUN_ROOT.'header.php';
     TO: require PUN_ROOT.'header_index.php';

I believe that is everything..  Give it a shot and let me know if you run into problems.  If you do I will guide you through it...

--
Robert
Administrator
NanoCubeForums.com

Re: PunBB Miniportal v1.2.x

you could do it without duplicating header.php and using a special define to use the portal template like the admin pages do

96

Re: PunBB Miniportal v1.2.x

Connorhd,

  I would agree, it could be done that way as well..  I did it this way because I wasn't sure if I would like it or not and I could just modify 2 important files slightly and be able to revert quickly.

  Can you post the method you propose with the define?

--
Robert
Administrator
NanoCubeForums.com

97

Re: PunBB Miniportal v1.2.x

Ataxy wrote:

ok here are my problem

i get this in my index page at the bottom
Notice: Undefined variable: output in /home/vhost/d-vault.peerforces.com/html/forum/index.php on line 29
---never mind this one it was caused by the chatbox---

I've just installed part 1 of this today and I cant get pass the above as well -- and i dont have any chatbox...(???)
Undefined variable: output in /data/4/0/51/132/214947/user/218384/htdocs/af3/forum/index.php on line 29

cant figure out what am i doing wrong.

98

Re: PunBB Miniportal v1.2.x

af3,

  Do you have gd installed for php?

--
Robert
Administrator
NanoCubeForums.com

99

Re: PunBB Miniportal v1.2.x

rjg, yes.  phpinfo shows gd2.

GD Support  enabled 
GD Version  2.0 or higher 
FreeType Support  enabled 
FreeType Linkage  with freetype 
GIF Read Support  enabled 
GIF Create Support  enabled 
JPG Support  enabled 
PNG Support  enabled 
WBMP Support  enabled

100

Re: PunBB Miniportal v1.2.x

you don't need gd support,

af3: are you sure there is some news in the forum you specified?