From 8bb9af10e1a8c01248526448dedb839afe9cac2a Mon Sep 17 00:00:00 2001 From: caiyuzheng <290198252@qq.com> Date: Thu, 29 Aug 2019 16:12:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E7=AB=A0=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Controllers/Blog.php | 18 +++++++++++++++--- App/Models/Doc.php | 7 +++++++ App/Views/blog/basic.html | 4 ++-- App/Views/blog/css/left.css | 3 +-- App/Views/blog/js/scripts.js | 14 +------------- Core/Controller.php | 2 -- public/index.php | 1 - 7 files changed, 26 insertions(+), 23 deletions(-) diff --git a/App/Controllers/Blog.php b/App/Controllers/Blog.php index 994989e..b9586cb 100644 --- a/App/Controllers/Blog.php +++ b/App/Controllers/Blog.php @@ -26,10 +26,22 @@ class Blog extends Controller View::renderTemplate("/blog/basic.html",['docs'=>$docs,'index'=>true]); } function articleAction(){ - View::renderTemplate("/blog/basic.html",['title'=>'test','index'=>false]); - //print_r($this->query_string); + if(sizeof($this->querys) != 0){ + echo '
'; + print_r($this->querys['title']); + $docModel = new Models\Doc(); + $doc = $docModel->titleDoc($this->querys['title']); + $markdown = new Parsedown; + $content = $markdown->text($doc[0]['content']); + echo ''; + View::renderTemplate("/blog/basic.html",['title'=>$this->querys['title'], + 'index'=>false, + 'content'=>$content]); + }else{ + View::renderTemplate("/blog/basic.html",['title'=>'test','index'=>false]); + } } function jsAction(){ - print_r($_SERVER); + //print_r($_SERVER); } } \ No newline at end of file diff --git a/App/Models/Doc.php b/App/Models/Doc.php index b9271c0..fae3a91 100644 --- a/App/Models/Doc.php +++ b/App/Models/Doc.php @@ -62,4 +62,11 @@ class Doc extends Model return $recv; } } + public function titleDoc($title){ + $db = static::getDB(); + $stmt = $db->query('select * from doc where title = \''.$title.'\''); + $recv = $stmt->fetchAll(); + return $recv; + } } + diff --git a/App/Views/blog/basic.html b/App/Views/blog/basic.html index 61bb0da..6cfb34b 100644 --- a/App/Views/blog/basic.html +++ b/App/Views/blog/basic.html @@ -135,10 +135,10 @@ {%else%}
- 测试 + {{ title }}