php前台模板,前台模板渲染及代码

摘要:<?php

namespace app\index\controller;

use app\admin\model\ProductModel;

use app\admin\model\SlideModel;

use app\admin\model\NewsModel;

use app\admin\model\SystemModel;

use&<?php

namespace app\index\controller;

use app\admin\model\ProductModel;

use app\admin\model\SlideModel;

use app\admin\model\NewsModel;

use app\admin\model\SystemModel;

use think\Controller;

use think\facade\Request;

class Index extends Controller

{

public function index()

{

//查询轮播图

$slide = new SlideModel();

$slides = $slide->select()

->toArray();

$this->view->slides = $slides;

//查询头牌

$product = new ProductModel();

$products = $product->where('sort','9')->select()->toArray();

$this->view->products = $products;

//查询新上

$NewProduct = $product->where('sort','12')->limit(1)

->select()->toArray();

$this->view->NewProduct = $NewProduct;

//查询最新资讯

$new = new NewsModel();

$news = $new->limit(4)->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排序

$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');

//通过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();

}

}

/*******************************************************************/html>

黑水国际

{include file="public/style"}

{include file="public/head"}

{volist name="slides" id="slide"}

{/volist}

新上精品

{volist name="products" id="product"}

                        

style=" width: 260px;height: 160px;" alt="">

{/volist}

丽春院百年老店

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

  • 新上花魁

    {volist name="NewProduct" id="NewProduct"}

                                

    style="border-radius:10px; box-shadow: 0 0 10px #eaeaea;   border:1px solid #E9E7E7;width: 300px;height: 300px;"

    alt="">

    {/volist}

  • 最新资讯

    {volist name="news" id="new"}

  •                                 

    style="border-radius:10px; box-shadow: 0 0 10px #6E6E6E;   width: 100px;height: 95px;"

    alt="">

    {$new.title}

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

    了解更多

{/volist}

{include file="public/foot"}

$(".slider").YuxiSlider({

width: 1900, //容器宽度

height: 450, //容器高度

control: $('.control'), //绑定控制按钮

during: 4000, //间隔4秒自动滑动

speed: 800, //移动速度0.8秒

mousewheel: true, //是否开启鼠标滚轮控制

direkey: true //是否开启左右箭头方向控制

});

批改老师:灭绝师太批改时间:2019-01-07 17:27:14

老师总结:学习进度保持的不错,希望学过的知识点都有好好掌握,必要的的地方敲上备注,便于修改和测试

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值