{include file="header.tpl"}{* body of template goes here *}{include file="footer.tpl"}
load_nav.php -------------<?php // load in variables from a mysql db and assign them to the template require_once("MySQL.class.php"); $sql = new MySQL; $sql->query("select * from site_nav_sections order by name",SQL_ALL); $this->assign('sections',$sql->record);?> index.tpl ---------{* absolute path, or relative to $trusted_dir *} {include_php file="/path/to/load_nav.php"}{foreach item="curr_section" from=$sections} <a href="{$curr_section.url}">{$curr_section.name}</a><br> {/foreach}
-------------<?php // load in variables from a mysql db and assign them to the template
require_once("MySQL.class.php");
$sql = new MySQL;
$sql->query("select * from site_nav_sections order by name",SQL_ALL);
$this->assign('sections',$sql->record);?>
index.tpl
---------{* absolute path, or relative to $trusted_dir *}
{include_php file="/path/to/load_nav.php"}{foreach item="curr_section" from=$sections}
<a href="{$curr_section.url}">{$curr_section.name}</a><br>
{/foreach}
$smarty->display( index.tpl);index.tpl
在tpl里是html语言写的你想写的东东
http://smarty.php.net/manual/en/api.fetch.php
sqlite.htm[主模版]
$tpl->assign("major",$major);
$vard = $tpl->fetch("sqlite_list.htm");
$tpl->assign("major",$vard);
$tpl->display("sqlite.htm");
就OK!