diff --git a/app/admin/controller/Post.php b/app/admin/controller/Post.php index f5119c8..bb1cb16 100644 --- a/app/admin/controller/Post.php +++ b/app/admin/controller/Post.php @@ -27,12 +27,19 @@ class Post extends Common { // - $list = ModelPost::with(['categorys.category', 'tags.tag']) + $model_list = ModelPost::with(['categorys.category', 'tags.tag']) ->where('type', $this->request->param('type', 1)) - ->order('id desc') - ->paginate([ - 'query' => $this->request->get() - ]); + ->order('id desc'); + + $category_id = $this->request->param('category_id', 0); + + if(!empty($category_id)){ + $model_list = $model_list->where('category_id', $category_id); + } + + $list = $model_list->paginate([ + 'query' => $this->request->get() + ]); View::assign('list', $list); @@ -90,7 +97,10 @@ class Post extends Common ]); } - return $this->success('添加成功', url('index', ['type' => $this->request->param('type')])); + return $this->success('添加成功', url('index', [ + 'type' => $this->request->param('type'), + 'category_id'=>$this->request->param('category_id'), + ])); } public function convertHtml2Markdown() diff --git a/app/common/tools/Site.php b/app/common/tools/Site.php index d0dbb9d..f0de652 100644 --- a/app/common/tools/Site.php +++ b/app/common/tools/Site.php @@ -7,13 +7,13 @@ class Site { public static function mapAllPost() { - $list_post = \app\model\Post::cache(60)->where('status', 1)->select(); + $list_post = \app\model\Post::cache(60)->where('type',3)->where('status', 1)->select(); return $list_post; } public static function mapRecentlyPost() { - $list_post = \app\model\Post::cache(60)->where('status', 1)->order('publish_time', "desc")->limit(25)->select(); + $list_post = \app\model\Post::cache(60)->where('type',3)->where('status', 1)->order('publish_time', "desc")->limit(25)->select(); return $list_post; } diff --git a/app/index/controller/Post.php b/app/index/controller/Post.php index 0316240..4cbcceb 100644 --- a/app/index/controller/Post.php +++ b/app/index/controller/Post.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace app\index\controller; use app\model\Post as ModelPost; +use app\model\PostCategory; use think\facade\Cache; use think\facade\View; use think\model\Relation; @@ -47,7 +48,10 @@ class Post extends Common $model_post->save(); + + View::assign('post', $model_post); + return View::fetch(); } diff --git a/app/model/Post.php b/app/model/Post.php index 8817909..7f43583 100644 --- a/app/model/Post.php +++ b/app/model/Post.php @@ -20,6 +20,7 @@ use think\Paginator; */ class Post extends Base { + use SoftDelete; // public static $autoClearCache = [ @@ -37,8 +38,6 @@ class Post extends Base 1 => '发布' ]; - use SoftDelete; - protected $defaultSoftDelete = 0; public function categorys() @@ -101,8 +100,8 @@ class Post extends Base public function getDescAttr($value) { - if(empty($value)){ - + if(empty($value)) { + } return $value; @@ -208,4 +207,19 @@ class Post extends Base return $share_text; } -} \ No newline at end of file + + public function getStartContentAttr() + { + $start_content = ''; + + $list_post_category_id = $this->getAttr('categorys')->column('category_id'); + + $list_start_post = Post::where('category_id', 'in', $list_post_category_id)->cache(600)->where('status', 1)->select(); + + foreach ($list_start_post as $k_start_post => $v_start_post) { + $start_content .= $v_start_post->content_html; + } + + return $start_content; + } +} diff --git a/view/admin/category/index.html b/view/admin/category/index.html index 718a7d4..fb11a3d 100644 --- a/view/admin/category/index.html +++ b/view/admin/category/index.html @@ -53,7 +53,9 @@ {$vo.id} {:str_repeat('|--',$vo.level)} {$vo.title} - {$vo.desc} + +

{$vo.desc}

+ {$vo.tpl_name} {$vo.sort} diff --git a/view/admin/post/create.html b/view/admin/post/create.html index 2a92bc4..b65342c 100644 --- a/view/admin/post/create.html +++ b/view/admin/post/create.html @@ -39,6 +39,7 @@
+
添加 @@ -51,7 +52,7 @@
- + {notin name='$Request.param.type' value='category-start,category-end' }
封面
@@ -64,6 +65,7 @@
+ {/notin}
描述
@@ -77,13 +79,14 @@
+ {notin name='$Request.param.type' value='category-start,category-end' }
发表时间
- + {/notin}
diff --git a/view/admin/post/edit.html b/view/admin/post/edit.html index 4ea1369..13d8641 100644 --- a/view/admin/post/edit.html +++ b/view/admin/post/edit.html @@ -52,7 +52,7 @@
- + {notin name='$Request.param.type' value='category-start,category-end' }
封面
@@ -65,13 +65,14 @@
- + {/notin}
描述
+ {notin name='$Request.param.type' value='category-start,category-end' }
作者名称 @@ -88,7 +89,7 @@
- + {/notin}
@@ -110,6 +111,7 @@
+ {notin name='$Request.param.type' value='category-start,category-end' }
发表时间
@@ -137,14 +139,6 @@
- -
-
排序
-
- -
越大越靠前
-
-
模板
@@ -155,9 +149,19 @@
+ {/notin} +
+
排序
+
+ +
越大越靠前
+
+
+ + {notin name='$Request.param.type' value='category-start,category-end' }
分类和标签 @@ -204,6 +208,7 @@
+ {/notin} diff --git a/view/admin/post/index.html b/view/admin/post/index.html index 5d127ef..fd128dd 100644 --- a/view/admin/post/index.html +++ b/view/admin/post/index.html @@ -32,7 +32,7 @@
- 添加 + 添加
diff --git a/view/index/post/read.html b/view/index/post/read.html index 7529da7..293980d 100644 --- a/view/index/post/read.html +++ b/view/index/post/read.html @@ -125,6 +125,7 @@ {/if}
+ {$post->start_content|raw} {$post->content_html_show|raw} {:\\app\\common\\tools\\PostBlock::copyright($post)}