1 (edited by Utchin 2008-01-16 14:30)

Topic: integrate punbb's template system

i am trying to implement punbb's template system into a little site i am making... its not using punbb, its a site i am coding for some knowledge...

i have looked around but i like the current punbb's template system.. its simple and easy to use...

in my own header.php i have added the loading of the templates

// Load the template
if (defined('PUN_ADMIN_CONSOLE'))
    $tpl_main = file_get_contents(PUN_ROOT.'include/template/admin.tpl');
else if (defined('PUN_HELP'))
    $tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl');
else if (defined('PUN_PORTAL'))
    $tpl_main = file_get_contents(PUN_ROOT.'include/template/portal.tpl');
else
    $tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl');

and Ive copied some of the str_replace codes like pun_status and and this had no luck..  I cannot seem to get my page to load the template??

how would I get it to work.. any hints?

at the moment i haved used the exact code... but when i get it working i will rewrite it

EDIT: just found http://www.punres.org/viewtopic.php?id=3483 which could do, but wpuld prefur .tpl?

Sorry. Unactive due to personal life.

Re: integrate punbb's template system

Matt, did u add the

define('PUN_PORTAL', 1);
to the top of each page that you wanted it to pull the portal.tpl?

line 1. <?php
line 2. define('PUN_PORTAL', 1);

example code of the index to pull the portal.tpl

<?php
define('PUN_PORTAL', 1);//special note! add this line to any page to pull the menu on left side!! 
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;
}
?>
 
        <div class="block">
            <h2><span>Welcome</span></h2>
            <div class="box">
                <div class="inbox">
                    <p>
                    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent augue. Nulla facilisi. Fusce bibendum accumsan erat. Quisque sollicitudin mattis neque. Sed dapibus. Integer a lectus eu sem consequat pellentesque. Morbi rhoncus nulla. Duis adipiscing interdum velit. Fusce ante. Ut vitae enim sit amet magna sodales hendrerit. In sed tortor at sapien convallis eleifend. Proin mauris. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut metus. Cras ac arcu et arcu porttitor blandit. Nam vitae lectus eget mauris sollicitudin placerat. Suspendisse vestibulum. Donec varius libero. Duis velit tellus, euismod vitae, consequat sed, consectetuer ut, purus.
                    </p>
                    <p>
                    Praesent viverra venenatis magna. Etiam in dolor. Ut in justo ac nibh malesuada cursus. Duis urna arcu, aliquam vitae, consequat nec, tincidunt non, mi. Nunc lobortis. Nunc pharetra. Sed porttitor. Maecenas turpis tortor, blandit nec, dignissim in, porttitor eu, odio. In hac habitasse platea dictumst. Suspendisse augue odio, ornare a, elementum ac, tincidunt varius, orci. Nulla libero ante, hendrerit ac, consectetuer eu, sollicitudin et, eros. Duis sapien. Suspendisse ornare enim sit amet dui. Donec ullamcorper diam.
                    </p>
                </div>
            </div>
        </div>
<?php
echo pun_news(1, 5, 0);
 
require PUN_ROOT.'footer.php';

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: integrate punbb's template system

i always try to put all my css stuff in the css files so i took the css part out of the portal.tpl and added it to the base.css so no matter what style i use it will give me the portal layout for the sidebar.

1.open base.css up
you can find this in the style/imports folder

at the top or bottom place this css

please make sure you remove this from the portal.tpl!!

 #left {
        width: 174px;
        float: left;
        margin-left:3px;
    }
    #main {
        margin-left: 186px;
        margin-right:6px;
    }
    #container {
        width: 100%;
        float: right;
        margin-left: -181px;
    }

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

4 (edited by Utchin 2008-01-16 15:35)

Re: integrate punbb's template system

yes i know that but, but i need the bit where it does all the str_replace in (header.php of punbb) to change it all up... that only sets it, it dosnt retvie the file contese so it only outputs what was in my file.php not the tpl file

becauese im not using punbb, i have made my own files... i dont have the code where it edited the tpl to have the right code in??
make sence?

Sorry. Unactive due to personal life.

Re: integrate punbb's template system

still making no sence...

All the $tpl_main is being defined but i cant seem to call it like punbb does??

I get it to work if i do echo $tpl_main but that isnt the case with punbb??

Sorry. Unactive due to personal life.

Re: integrate punbb's template system

oh ok.. i thought that you needed the defien statement.. my bad..

im trying to understand what u mean ... u need the code that pulls the tpl from the header?



Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: integrate punbb's template system

yes...lol...

its verry simple... i just want it for learining and developing perpous as i have learn all my php/mysql skills from punbb... and just want to create a small dynamic site...

Sorry. Unactive due to personal life.

Re: integrate punbb's template system

i mostly take the wordpress to punbb tpl
and wrap my html inside it and use the puntags to place my stuff...

so i can have a normal css template as a punbb style.

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: integrate punbb's template system

I  want to learn about coding a new site, not relly editing and exisiting one..

I was thinking of making a VERRY simple site... mainly aimed at small comanys who just want a simple website... People use wordpress and joomla but they have many features they dont want.

basicly its just going to be a stand-alone site where they can create pages with html code,and manage it via and admin panel...


and the template system is so i can edit the style for each site easly...
I am trying to stay away from free software, certianly with punbb if you sell it, then the person can give it on free... and i may charge for it (if i belive if it is at a good charagble level) but stuff like SMARTY tempalte could be the same..

Sorry. Unactive due to personal life.

10

Re: integrate punbb's template system

this is the site that got me started playing around with css templates and main.tpl
then i started learning about the portal.tpl and what i could do with it.
a site that sorta slow that i did but is completely controlled by punbb is
http://modelcrowd.com  i took a (wordpress template) searched and fount the css template and started creating a punbb style.
i had coppermine and wp and punbb all in one integration but i didnt like all the admin panels to do everything.
so i killed wp and cpg.. ended up doing my own simple gallery

http://almosteffortless.com/2005/09/25/ … and-punbb/


Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

11 (edited by Utchin 2008-01-18 23:37)

Re: integrate punbb's template system

Not sure if your quite getting me lol


I DONT want to use punbb.....lol I have used punbb for all my sites, and its tought me allot about php, but i couldnt even connect to a database as im used to doing it the punbb way ( so to speak)..
It pretty pointless if i only can use punbb and no other custom sites...

However i want to use the punbb template method without using punbb ....

Question: what files mange the tpl.. $tpl_main is it just header.php?


I have tried using

// Spit out the page
exit($tpl_main);

but no luck?

Sorry. Unactive due to personal life.