index.php查询,这个是前台的index.php
public function index()
{$slideImgs = Db::name("slideimg")->where("status",'=','normal')->limit(5)->order('sort','desc')->select();$productList = Db::name("product")->where("deletetime",'exp','is null')->limit(10)->order('updatetime','desc')->select();$this->view->assign('slideImgs',$slideImgs);$this->view->assign('productList',$productList);$this->view->assign('title', __('首页'));//设置页面名称,方便根据页面名称加载不同的js和css$this->view->assign('pageName','index' );return $this->view->fetch();
}
模板代码
<div><!--{php}print_r($slideImgs);{/php}--><!--{php}print_r($productList);{/php}-->{foreach $slideImgs as $key=>$img }<img src="{$img.image}"/>{/foreach}{foreach $productList as $key=>$product }<img src="{$product.product_image}"/><div>{$product.name}</div><div>{$product.marketPrice}</div>{/foreach}
</div>
结果