国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

新聞中心新聞數(shù)據(jù)查詢賦值實(shí)現(xiàn)代碼

Original 2018-12-23 00:49:39 264
abstract:view\index\news.html代碼<!doctype html> <html> <head>     <meta charset="UTF-8">     <meta name="viewport

view\index\news.html代碼

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>麗春院 — 新聞中心</title>
    {include file="public/style"}
</head>
<body>
<div id="page">
    {include file="public/head"}
    <div id="body">
        <div class="header">
            <div>
                <h1 style="color: #6E6E6E; font-family: YouYuan; font-weight: bold">新聞中心</h1>
                <div class="article">
                    <ul> 
                        {volist name="news" id="new"}
                        <li>
                            <a href="{:url('ConNew')}?id={$new.id}" target="_blank"><img src="{:GetNewsPic($new.id)}" style="border-radius:10px; box-shadow: 0 0 0px #6E6E6E;   width: 100%;height: 100%;" alt=""></a>
                            <h1>{$new.title}</h1>
                            <span style="color: #0C0C0C">{$new.time|date="Y.m.d"}</span>
                            <p style="color: #0C0C0C">{$new.desc}</p>
                            <a href="{:url('ConNew')}?id={$new.id}" target="_blank" class="more">閱讀更多</a>
                        </li>
                        {/volist}
                    </ul>
                </div>
                <div class="sidebar">
                    <ul>
                        <li>
                            <h1>熱門新聞</h1>
                            {volist name="hotNews" id="hotNew"}
                            <a href="{:url('ConNew')}?id={$hotNew.id}" target="_blank"><img src="{:GetNewsPic($hotNew.id)}" style="border-radius:10px; box-shadow: 0 0 5px #6E6E6E;   width: 340px;height: 188px;" alt=""></a>
                            <h2>{$hotNew.title}</h2>
                            <span>{$hotNew.desc}</span>
                            {/volist}
                        </li>
                        <li>
                            <h1>最新發(fā)布</h1>
                            <ul>
                                {volist name="newNews" id="newNew"}
                                <li>
                                    <a href="{:url('ConNew')}?id={$newNew.id}" target="_blank"><img src="{:GetNewsPic($newNew.id)}" style="border-radius:10px; box-shadow: 0 0 2px #6E6E6E;   width: 60px;height: 55px;" alt=""></a>
                                    <h2 style="font-size: 15px;">{$newNew.title}</h2>
                                    <span>{$newNew.time|date="Y.m.d"}</span>
                                </li>
                                {/volist}
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="page">
            <div>
                {$news|raw}
            </div>
        </div>
    </div>
    {include file="public/foot"}
</div>
</body>
</html>

view\index\con_new.html代碼

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>麗春院 — 新聞詳細(xì)</title>
    {include file="public/style"}
</head>
<body>
<div id="page">
    {include file="public/head"}
    <div id="body">
        <div class="header">
            <div>
                <h1 style="color: #6E6E6E; font-family: YouYuan; font-weight: bold">新聞詳細(xì)</h1>
                <div class="article">
                    <img src="{:GetNewsPic($new.id)}" style="border-radius:10px; box-shadow: 0 0 5px #6E6E6E;   width: 560px;height: 240px;" alt="">
                    <div style="border-radius:10px; box-shadow: 0 0 5px #6E6E6E; background: #BDBDBD; padding: 20px;">
                        <h1 style=" text-align:center; color: #000;">{$new.title}</h1>
                        <span style="color: #0C0C0C">{$new.time|date="Y.m.d"}</span>
                        <p>{:htmlspecialchars_decode($new.content)}</p></div>
                </div>
                <div class="sidebar">
                    <ul>
                        <li>
                            <h1>熱門新聞</h1>
                            {volist name="hotNews" id="hotNew"}
                            <a href="{:url('ConNew')}?id={$hotNew.id}" target="_blank"><img src="{:GetNewsPic($hotNew.id)}" style="border-radius:10px; box-shadow: 0 0 5px #6E6E6E;   width: 340px;height: 188px;" alt=""></a>
                            <h2>{$hotNew.title}</h2>
                            <span>{$hotNew.desc}</span>
                            {/volist}
                        </li>
                        <li>
                            <h1>最新發(fā)布</h1>
                            <ul>
                                {volist name="newNews" id="newNew"}
                                <li>
                                    <a href="{:url('ConNew')}?id={$newNew.id}" target="_blank"><img src="{:GetNewsPic($newNew.id)}" style="border-radius:10px; box-shadow: 0 0 2px #6E6E6E;   width: 60px;height: 55px;" alt=""></a>
                                    <h2 style="font-size: 15px;">{$newNew.title}</h2>
                                    <span>{$newNew.time|date="Y.m.d"}</span>
                                </li>
                                {/volist}
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    {include file="public/foot"}
</div>
</body>
</html>

controller\Index.php代碼

<?php
namespace app\index\controller;
use think\Controller;
use think\facade\Request;
use app\admin\model\SlideModel;
use app\admin\model\ProductModel;
use app\admin\model\NewsModel;
use app\admin\model\SystemModel;
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',7)->select()->toArray();
        $this->view->products=$products;        
        //查詢新上花魁并給模板賦值
        $NewProduct = $product->where('sort',5)->limit(1)->select()->toArray();
        $this->view->NewProduct=$NewProduct;
        //查詢最新資訊并給模板賦值
        $new = new NewsModel();
        $news = $new->limit(2)->select()->toArray();
        $this->view->news=$news;
        //渲染首頁(yè)模板
        return $this->fetch();
    }
    public function about()
    {
        //查詢系統(tǒng)設(shè)置并給模板賦值
        $system = new SystemModel();
        $systems = $system->select()->toArray();
        $this->view->systems=$systems;
        //渲染關(guān)于我們模板
        return $this->fetch();
    }
    public function product()
    {
        //查詢?nèi)慨a(chǎn)品并給模板賦值
        $product = new ProductModel();
        $products = $product->order('id','desc')->paginate(4);
        $this->view->products=$products;        
        //渲染產(chǎn)品展示模板
        return $this->fetch();
    }
    public function ConPro()
    {
        //獲取產(chǎn)品id
        $ProId = Request::param('id');
        //查詢產(chǎn)品并給模板賦值
        $product = ProductModel::get($ProId);
        $this->view->product=$product;   
        //渲染產(chǎn)品詳細(xì)頁(yè)模板
        return $this->fetch();
    }
    public function news()
    {
        //查詢?nèi)啃侣劜⒔o模板賦值
        $new = new NewsModel();
        $news = $new->order('id','desc')->paginate(4);
        $this->view->news=$news;
        //查詢熱門新聞并給模板賦值
        $hotNews = $new->limit(1)->select()->toArray();
        $this->view->hotNews=$hotNews;
        //查詢最新發(fā)布新聞并給模板賦值
        $newNews = $new->limit(6)->select()->toArray();
        $this->view->newNews=$newNews; 
        //渲染新聞中心模板
        return $this->fetch();
    }
    public function ConNew()
    {
        //獲取新聞id
        $newId = Request::param('id');
        //查詢新聞并給模板賦值
        $new = NewsModel::get($newId);
        $this->view->new=$new;
        //查詢熱門新聞并給模板賦值
        $hotNews = $new->limit(1)->select()->toArray();
        $this->view->hotNews=$hotNews;
        //查詢最新發(fā)布新聞并給模板賦值
        $newNews = $new->limit(6)->select()->toArray();
        $this->view->newNews=$newNews;        
        //渲染新聞詳細(xì)頁(yè)模板
        return $this->fetch();
    }

}


Correcting teacher:天蓬老師Correction time:2018-12-23 10:31:31
Teacher's summary:作業(yè)寫的不錯(cuò),注釋比較清晰,繼續(xù)努力,加油

Release Notes

Popular Entries