Developer News

XOOPS.org running Smarty template engine

onokazu  23-Aug-2002 00:04 12578 Reads   No comments 
function themeheader($show_rblock) {
    global 
$xoopsConfig;
    echo 
'';
    
OpenWaitBox();
    echo 
'bgcolor="#666666">
    
    
    
    
    
    .XOOPS_URL.'">
    .XOOPS_URL.'/themes/phpkaox/images/logo.gif">
    
    
    '
;
    if ( 
$xoopsConfig['banners'] == ) {
    
showbanner();
    }
    echo 
'
    
    
    
    
    
    
    cellspacing="0" cellpadding="0" height="100%">
    
    valign="top" align="center">'
;
    
make_sidebar("left");
    echo 
'
    '
;
}

function 
themefooter($show_rblock$footer) {
    echo 
"";
    if ( 
$show_rblock ) {
    echo 
'';
    
make_sidebar("right");
    }
    echo 
'
    '
;
    echo 
$footer;
    echo 
'
    
    '
;
    
CloseWaitBox();
}

function 
themesidebox($title$content) {
    echo 
'
    
    '
.$title.'
    
    
    '
.$content.'
    
    
'
;
}


whereas when we use Smarty, the layout.tpl file which defines the total look of the site will become:

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html>
<
head>
<
meta http-equiv='Content-Type' content='text/html; charset={$xoops_charset}' />
<
meta name='keywords' content='' />
<
meta name='description' content='' />
<
meta name='generator' content='{$xoops_version}' />
<
title>{$xoops_pagetitle}title>
<
link rel='stylesheet' type='text/css' media='all' href='{$xoops_url}/xoops.css' />
{if 
$xoops_themecss != ""}
<
style type='text/css' media='all'>style>
{/if}
<
link href='{$xoops_url}/favicon.ico' rel='SHORTCUT ICON' />
<
script src='{$xoops_url}/include/xoopsjs.php'>script>
head>
<
body>
<
table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#666666">
  <
tr>
    <
td valign="top" bgcolor="#DDE1DE">
      <
table width="100%" border="0" cellspacing="0" cellpadding="0">
        <
tr>
          <
td width="285" valign="middle" align="center">
            <
a href="{$xoops_url}/">
              <
img src="{$xoops_url}/themes/phpkaox/images/logo.gif">
              a>
          td>
          <
td>
          {if 
$xoops_banner != ""}
            {
$xoops_banner}
          {else}
              
          {/if}
          td>
        tr>
      table>
    td>
  tr>
  <
tr>
    <
td valign="top" bgcolor="#FFFFFF">
      <
table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
        <
tr>
          <
td width="20%" bgcolor="#EFEFEF" valign="top">
          {foreach 
item=block from=$xoops_lblocks}
            <
table width="100%" border="0" cellspacing="0" cellpadding="2">
              <
tr>
                <
td bgcolor="#E2DBD3">
                  <
b><font color="#666600">{$block.title}font>b>
                td>
              tr>
              <
tr>
                <
td valign="top">{$block.content}td>
              tr>
            table>
            <
br>
          {/foreach}
          td>
          <
td valign="top">
          {if 
$xoops_contents_tpl == ""}
            {
$xoops_contents}
          {else}
            {include 
file="$xoops_contents_tpldir/$xoops_contents_tpl"}
          {/if}
          td>
          {if 
$xoops_showrblock == 1}
      <
td width="20%" bgcolor="#efefef" valign="top">";
          {foreach item=block from=
$xoops_rblocks}
            100%" border="0" cellspacing="0" cellpadding="2">
              
                #E2DBD3">
                  
<b><font color="#666600">{$block.title}font>b>
                td>
              tr>
              <
tr>
                <
td valign="top">{$block.content}td>
              tr>
            table>
            <
br>
          {/foreach}
          td>
          {/if}
        tr>
      table>
    td>
  tr>
  <
tr>
    <
td height="30" valign="middle" bgcolor="#DDE1DE" align="center">
    {
$xoops_footer}
    td>
  tr>
table>
body>
html>


Now as you may have noticed, Smarty does not attempt to completely separate logic from the templates. There do exist some Smarty's proprietary logical functions and parameters within template files. However, that is almost ignorable compared to the amount of PHP codes we had in our old theme files, and also there is already a detailed manual on how to use them which you could see at http://smarty.php.net/.

Not only theme files, but each module can have its own template files. We have already converted the forums module running on this site. Though not 100% required, it is highly recommended that all modules use templates, and we will be publishing a detailed doc on how to create template files for a module.

The bad news is that modules utilizing template files will not work under old themes...which also means that all themes should be converted to use Smarty template files.

That's it for now, please report bugs as usual so that we can have the next release as soon as possible.
Rating 0/5
Rating: 0/5 (0 votes)
Voting is disabled!


Login

Who's Online

250 user(s) are online (58 user(s) are browsing Publisher)


Members: 0


Guests: 250


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits

Categories