[Chongqing Normal University] PHP blog training -Thinkphp

Database Design

CREATE TABLE `user` (
    `user_id` int unsigned NOT NULL AUTO_INCREMENT,
    username` VARCHAR `( 255 ) the COMMENT ' username ' ,
    password` longtext the COMMENT ` ' password ' ,
    create_ts` ` int the COMMENT ' creation time ' ,
    update_ts` ` int the COMMENT ' modified ' ,
    PRIMARY KEY (`user_id`)
);

CREATE TABLE `article` (
    `article_id` int unsigned NOT NULL AUTO_INCREMENT,
    `user_id` int unsigned COMMENT '用户ID',
    title` VARCHAR `( 255 ) the COMMENT ' article title ' ,
    content` longtext the COMMENT ` ' article content ' ,
    create_ts` ` int unsigned the COMMENT ' creation time ' ,
    update_ts` ` int unsigned the COMMENT ' modified ' ,
    PRIMARY KEY (`article_id`)
);

Design front page

1. Download blog templates

Without further ado, light blog template: https://fly.layui.com/store/layuiXianyan/

 

2. Configuration Templates

In the first extract public / static / directory:

 

 Similar to enter the directory  D: \ php \ project \ tp \ public \ static \ xianyan-1.0 \ html \ follows:

 

 All the html files to be copied is similar to  D: \ php \ project \ tp \ application \ index view \ blog \ \ directory to the following:

 

 Finally, you need to create a controller, modify html resource path to index.html, for example,

controller/Index.php 

<?php
namespace app\index\controller;

class Index
{
    public function index()
    {
        return view('blog/index');
    }
}

view/blog/index.html 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <Title> Without further ado, light blog </ title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="__ROOT__/static/xianyan-1.0/res/layui/css/layui.css">
    <link rel="stylesheet" href="__ROOT__/static/xianyan-1.0/res/static/css/mian.css">
</head>
<body class="lay-blog">
        <div class="header">
            <div class="header-wrap">
                <h1 class="logo pull-left">
                    <a href="index.html">
                        <img src="__ROOT__/static/xianyan-1.0/res/static/images/logo.png" alt="" class="logo-img">
                        <img src="__ROOT__/static/xianyan-1.0/res/static/images/logo-text.png" alt="" class="logo-text">
                    </a>
                </h1>
                <form class="layui-form blog-seach pull-left" action="">
                    <div class="layui-form-item blog-sewrap">
                        <div class="layui-input-block blog-sebox">
                          <i class="layui-icon layui-icon-search"></i>
                          <input type="text" name="title" lay-verify="title" autocomplete="off"  class="layui-input">
                        </div>
                    </div>
                </form>
                <div class="blog-nav pull-right">
                    <ul class="layui-nav pull-left">
                      <li class="layui-nav-item layui-this"><a href="index.html">首页</a></li>
                      <li class="layui-nav-item"><a href="message.html">留言</a></li>
                      <li class="layui-nav-item"><a href="about.html">关于</a></li>
                    </ul>
                    <a href="#" class="personal pull-left">
                        <i class="layui-icon layui-icon-username"></i>
                    </a>
                </div>
                <div class="mobile-nav pull-right" id="mobile-nav">
                    <a href="javascript:;">
                        <i class="layui-icon layui-icon-more"></i>
                    </a>
                </div>
            </div>
            <ul class="pop-nav" id="pop-nav">
                <li><a href="index.html">首页</a></li>
                <li><a href="message.html">留言</a></li>
                <li><a href="about.html">关于</a></li>
            </ul>
        </div>
        <div class="container-wrap">
            <div class="container">
                    <div class="contar-wrap">
                        <h4 class="item-title">
                            <the p-> <i class = " layui-icon layui-icon-Speaker " > </ i> Notice: <span> Welcome to my blog Light </ span> </ p>
                        </h4>
                        <div class="item">
                            <div class="item-box  layer-photos-demo1 layer-photos-demo"><h3> <a href= "details.html"
                                 > has a poetic state of mind, in order to have a poetic life </a> </ h3>
                                <H5> Posted on: <span> just </ span> </ h5>
                                <P> father as a mountain, poor expression. Looking back ten years ago, I remember my father always had a generous shoulders, sat on a small cross himself, crossed the sea of ​​people to see a wider sky, that time expect that they have a pair of wings, they can fly high like a bird, far-sighted. Although his father and sometimes his own joke, but when something wrong will be severely reprimanded. Father double big rough hands, taught me to walk, ride, but it will decisively open at a time to let go let yourself go bold attempt, at that time expected to grow up quickly, can do what you want to do, do not by his father "control." Wisdom Tree father, his all-knowing, omniscient, though you have a hundred thousand why, but also beat him. </ P>
                                <img src="__ROOT__/static/xianyan-1.0/res/static/images/item.png" alt="">
                            </div>
                            <div class="comment count">
                                <a href="details.html#comment">评论</a>
                                <a href="javascript:;" class="like">点赞</a>
                            </div>
                        </div>
                        <div class="item">
                            <div class="item-box  layer-photos-demo2 layer-photos-demo"><h3> <a href= "details.html"
                                 > has a poetic state of mind, in order to have a poetic life </a> </ h3>
                                <H5> Posted on: <span> just </ span> </ h5>
                                <P> father as a mountain, poor expression. Looking back ten years ago, I remember my father always had a generous shoulders, sat on a small cross himself, crossed the sea of ​​people to see a wider sky, that time expect that they have a pair of wings, they can fly high like a bird, far-sighted. Although his father and sometimes his own joke, but when something wrong will be severely reprimanded. Father double big rough hands, taught me to walk, ride, but it will decisively open at a time to let go let yourself go bold attempt, at that time expected to grow up quickly, can do what you want to do, do not by his father "control." Wisdom Tree father, his all-knowing, omniscient, though you have a hundred thousand why, but also beat him. </ P>
                                <img src="__ROOT__/static/xianyan-1.0/res/static/images/item.png" alt="">
                            </div>
                            <div class="comment count">
                                <a href="details.html#comment">评论</a>
                                <a href="javascript:;" class="like">点赞</a>
                            </div>
                        </div>
                        <div class="item">
                            <div class="item-box  layer-photos-demo3 layer-photos-demo"><h3> <a href= "details.html"
                                 > has a poetic state of mind, in order to have a poetic life </a> </ h3>
                                <H5> Posted on: <span> just </ span> </ h5>
                                <P> father as a mountain, poor expression. Looking back ten years ago, I remember my father always had a generous shoulders, sat on a small cross himself, crossed the sea of ​​people to see a wider sky, that time expect that they have a pair of wings, they can fly high like a bird, far-sighted. Although his father and sometimes his own joke, but when something wrong will be severely reprimanded. Father double big rough hands, taught me to walk, ride, but it will decisively open at a time to let go let yourself go bold attempt, at that time expected to grow up quickly, can do what you want to do, do not by his father "control." Wisdom Tree father, his all-knowing, omniscient, though you have a hundred thousand why, but also beat him. </ P>
                                <img src="__ROOT__/static/xianyan-1.0/res/static/images/item.png" alt="">
                            </div>
                            <div class="comment count">
                                <a href="details.html#comment">评论</a>
                                <a href="javascript:;" class="like">点赞</a>
                            </div>
                        </div>
                    </div>
                    <div class="item-btn">
                        <button class="layui-btn layui-btn-normal">下一页</button>
                    </div>
            </div>
        </div>
        <div class="footer">
            <p>
                <span>&copy; 2018</span>
                <span><a href="http://www.layui.com" target="_blank">layui.com</a></span> 
                <span>MIT license</span>
            </p>
            <P> <span> Life is a practice </ span> </ p>
        </div>
    <script src="__ROOT__/static/xianyan-1.0/res/layui/layui.js"></script>
    <script>
        layui.config({
          base: '__ROOT__/static/xianyan-1.0/res/static/js/' 
        }).use('blog');    
    </script>
</body>
</html>

Finally achieve the desired effect:

 

 Write logical development

To explain the classroom.

Guess you like

Origin www.cnblogs.com/jiangxiaobo/p/11932188.html