smarty v2在超过1个文件上分配变量

时间:2014-08-23 20:11:13

标签: php smarty wrapper smarty2

好吧所以我正在尝试制作一个聪明的页面包装器。我使用.php来加载我想用smarty分配的大部分设置。我还使用全局文件和路径文件来设置路径的常量,并加载smarty和其他类。

我的问题是当我转到页面时我想转到tpl设计显示bbut包含文件中的php没有做任何事情,或者它是聪明的并不是抓取数据来显示它。

的index.php

    switch($view)
    {
        case $view;
        $cview=basename($view, '.php');
        $smarty->assign('page_header', ucfirst($cview));
        $sfile="$cview.tpl";
        $fileinfo=$root."Pages/".$view;
        if(file_exists($fileinfo))
        {
            include_once($fileinfo);
        }
        else
        {
            header("HTTP/1.0 404 Not Found"); 
            include_once($root."Pages/404.php");
        }
        break;
    }

现在这部分有效,但它是我遇到问题的页面中的php文件。

about.php

global $db,$smarty;
$abt=$db->select("settings_pages", "sval", ["sname" => 'about_us']);
$smarty->assign("aboutus", $abt);
$smarty->display("about.tpl");

它显示了tpl,但现在不提取数据让我们看看about.tpl

about.tpl

{include file="header.tpl"}
<!-- START small_banner -->
  <section class="small_banner">
     <div class="center-wrap">
        <p class="page-banner-heading">{$page_header}</p>
        <div id="banner-search" style="display: hidden;">
           <form method="get" class="searchform" action="#">
              <fieldset>
                 <input type="text" name="s" class="s" value="Search..." onfocus="if(this.value=='Search...')this.value='';" onblur="if(this.value=='')this.value='Search...';" />
              </fieldset>
           </form>
        </div>
        <!-- END banner-search -->
        <div class="breadcrumbs"><a href="">Home</a> &rarr; <a>Pages</a> &rarr; <span class="current_crumb">About Us </span>
        </div>
        <!-- END breadcrumbs -->
     </div>
     <!-- END center-wrap -->

     <div class="shadow top"></div>
     <div class="shadow bottom"></div>
     <div class="tt-overlay"></div>
</section>

<section id="content-container" class="clearfix">
     <div id="main-wrap" class="clearfix">
        <div class="two_third">
            <p>
            {section name=about loop=$aboutus}
                {$aboutus[about]}
            {/section}
            </p>
        </div>

        <div class="one_third">
           <div class="img-frame full-third-short"><a href="#" target="_self"><img src="{$cimg}/online-shopping-280x124.jpg" alt="Wordpress Professional Expert" width="280" height="124" /></a></div>
           <h4>filler text</h4>
           <p>Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec id elit non mi porta gravida at eget metus. Lorem ipsum dolor.</p>
        </div>
        <div class="column-clear">&nbsp;</div>
        <p>&nbsp;</p>

     </div>
     <!-- END main-wrap -->   
  </section>
  <!-- END content-container -->
{include file="footer.tpl"}

请有人指出我做错了什么

0 个答案:

没有答案