Topic: php in main.tpl

can i use php in main.tpl?
and if so
how could i do: if your on index.php, show <div class=box>
but if your on any other page, dont show <div class=box>

any ideas?

Re: php in main.tpl

Not directly
http://punbb.org/docs/faq.html#faq3_4

3 (edited by pogenwurst 2007-06-22 19:29)

Re: php in main.tpl

Yes, see: http://punbb.org/docs/faq.html#faq3_4 (edit: darnit Smartys tongue)

To discern whether or not a user is on the index, use something like

if(basename($_SERVER['PHP_SELF'], 'php') == 'index')
{
     ...
}
Looking for a certain modification for your forum? Please take a look here before posting.

4 (edited by raptrex 2007-06-22 21:02)

Re: php in main.tpl

hmm my "sidebar" aint showing up
heres my main.tpl

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html dir="<pun_content_direction>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<pun_char_encoding>" />
<pun_head>
<style type="text/css">
    #left {
        width: 140px;
        float: left;
    }
    #main {
        margin-left: 150px;
    }
    #container {
        width: 100%;
        float: right;
        margin-left: -140px;
    }
</style>
</head>
<body>
 
<div id="punwrap">
<div id="pun<pun_page>" class="pun">
 
<div id="brdheader" class="block">
    <div class="box">
        <div id="brdtitle" class="inbox">
            <pun_title>
            <pun_desc>
        </div>
        <pun_navlinks>
        <pun_status>
    </div>
</div>
 
<div id="container">
    <div id="main">
    
        <pun_announcement>
    
        <pun_main>
        
    </div>    
</div>
 
<pun_include "sidebar.php">
 
<div class="clearer"></div>
 
<pun_footer>
 
</div>
</div>
 
</body>
</html>

and heres my sidebar.php in /include/user

<?php 
if(basename($_SERVER['PHP_SELF'], 'php') == 'index')
{
?>
<div id="left">    
    <div class="block">
        <h2><span>Menu</span></h2>
        <div class="box">
        <pun_sidelinks>            
        </div>
    </div>     
    
    <div class="block">
        <h2><span>Whos Online?</span></h2>
        <div class="box">
        <pun_online>
        </div>
    </div>
</div>    
<?php
}
else {
}

?>

my punbb is modified like how connorhd miniportal which i have an index.php which i want the sidebar to show and a forum.php which i just want the forum without a sidebar

Re: php in main.tpl

Oops, I left out a period. I should have written

if(basename($_SERVER['PHP_SELF'], '.php') == 'index')
{
     ...
}

By the way, the empty else {} is unnecessary and I'm not sure if template tags (like <pun_sidelinks> and <pun_online>) will work within a PHP.

Looking for a certain modification for your forum? Please take a look here before posting.

6 (edited by raptrex 2007-06-22 22:42)

Re: php in main.tpl

<pun_online> and <pun_sidelinks> work within a php file
now i just need to get my css to work
thx pogenwurst

one more question
can you include an external stylesheet in a tpl file?
or would it be better to put it in the header.php file

Re: php in main.tpl

raptrex wrote:

<pun_online> and <pun_sidelinks> work within a php file

Cool, I'm glad it worked then.

raptrex wrote:

can you include an external stylesheet in a tpl file?
or would it be better to put it in the header.php file

It doesn't really matter either way; adding it into the template would be easier however.

Looking for a certain modification for your forum? Please take a look here before posting.