结合本章学习内容,完成前台模块

Original 2019-08-12 16:48:07 350
abstract:controller/Index.php

1.png

controller/Index.php

select()->toArray(); $this->view->slides = $slides; //头牌人选 $product = new ProductModel(); $products = $product->where('sort','1')->select()->toArray(); $this->view->products = $products; //新上花魁 $NewProduct = $product->where('sort','2')->limit(1)->select()->toArray(); $this->view->NewProduct = $NewProduct; //查询最新资讯 $new = new NewsModel(); $news = $new->limit(2)->select()->toArray(); $this->view->news = $news; //渲染首页模板 return $this->fetch(); } public function about() { $system = new SystemModel(); $systems = $system->select()->toArray(); $this->view->systems = $systems; return $this->fetch(); } public function product() { $product = new ProductModel(); $products = $product->order('id','desc')->paginate(4); $this->view->products = $products; return $this->fetch(); } public function news() { //实例化模型 $new = new NewsModel(); //查询数据按照id的顺序进行查询并且每页4条数据 $news = $new->order('id','desc')->paginate(4); //给摸板赋值 $this->view->news = $news; //热门新闻 $hotNew = $new->limit(1)->select()->toArray(); $this->view->hotNews = $hotNew; //最新发布 $newNews = $new->limit(6)->select()->toArray(); $this->view->newNews = $newNews; return $this->fetch(); } public function ConNew() { $newId = Request::param('id'); $new = NewsModel::get($newId); $this->view->new = $new; //热门新闻 $hotNew = $new->limit(1)->select()->toArray(); $this->view->hotNews = $hotNew; //最新发布 $newNews = $new->limit(6)->select()->toArray(); $this->view->newNews = $newNews; //渲染首页模板 return $this->fetch(); } public function ConPro() { //获取产品id $ProId = Request::param('id'); $product = ProductModel::get($ProId); $this->view->product = $product; //渲染首页模板 return $this->fetch(); } }

public/style.html

       

public/head.html

public/floor.html

view/about.html

     xxx — 关于我们 {include file="public/style"} 
{include file="public/head"}
{volist name="systems" id="system"}

关于我们

{$system.about_title}

{$system.about_content}

{$system.ci_title}

{$system.ci_content}

{/volist}

百年老店

本着一心为客官服务的心做事、我们这里拥有十分美貌的姑娘和周到完美的服务!

{include file="public/floor"}

view/news.html

     xxx — 新闻中心 {include file="public/style"} 
{include file="public/head"}

新闻中心

    {volist name="news" id="new"}
  • {$new.title}

    {$new.time|date="Y-m-d"}

    {$new.desc}

    阅读更多
  • {/volist}
{$news|raw}
{include file="public/floor"}

view/index.html

     xxx — 首页 {include file="public/style"} {include file="public/head"} 
    {volist name="slides" id="slide"}
  • {$slide.desc}
  • {/volist}

头牌人选

    {volist name="products" id="product"}
  • {$product.desc}
  • {/volist}

xxx

为看官提供更养眼、更多样、更直观的感觉体验!

{include file="public/floor"}

view/con_new

     xxx — 新闻详细 {include file="public/style"} 
{include file="public/head"}

新闻详细

{$new.title}

{$new.time|date="Y-m-d"}

{:htmlspecialchars_decode($new.content)}

Correcting teacher:天蓬老师Correction time:2019-08-15 10:54:00
Teacher's summary:以后这样的渲染, 推荐写出明确的模板名称:return $this->fetch();

Release Notes

Popular Entries