diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index 13e0e2e5..46393073 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -99,6 +99,21 @@ class Article extends Common $share_config = $this->getSysConfig($this->lang_id, ['article_share']); View::assign('share_config', $share_config['article_share']); + // 获取文章评论数据 + $comments = ArticleLeaveMessageModel::field([ + 'id', + 'name', + 'email', + 'content', + 'created_at' + ]) + ->article($id) + ->audited(true) + ->order(['id' => 'desc']) + ->limit(5) + ->select(); + View::assign('comments', $comments); + // 获取倒序或发布时间倒序3篇文章做为推荐文章 $recommends = ArticleModel::field([ 'id', diff --git a/app/index/model/ArticleLeaveMessageModel.php b/app/index/model/ArticleLeaveMessageModel.php index 77e40652..793f1c95 100644 --- a/app/index/model/ArticleLeaveMessageModel.php +++ b/app/index/model/ArticleLeaveMessageModel.php @@ -16,4 +16,16 @@ class ArticleLeaveMessageModel extends ArticleLeaveMessageBaseModel use SoftDelete; // 软删除字段 protected $deleteTime = 'deleted_at'; + + // 文章文章范围查询 + public function scopeArticle($query, $article_id) + { + $query->where('article_id', '=', $article_id); + } + + // 审核状态范围查询 + public function scopeAudited($query, bool $is_audited = true) + { + $query->where('is_audited', '=', (int)$is_audited); + } } diff --git a/app/index/view/pc/article/detail.html b/app/index/view/pc/article/detail.html index 7001c60c..abc0b324 100644 --- a/app/index/view/pc/article/detail.html +++ b/app/index/view/pc/article/detail.html @@ -3,170 +3,161 @@ {notempty name="detail.seo_title"}{$detail.seo_title}{else /}{__BLOCK__}{/notempty} {/block} {block name="seo"} -{notempty name="detail.seo_keywords"} - - -{else /} -{__BLOCK__} -{/notempty} + {notempty name="detail.seo_keywords"} + + + {else /} + {__BLOCK__} + {/notempty} {/block} {block name="style"} {/block} {block name="main"}
- -
-
-
-

{$detail.title}

-

{$detail.release_time}

-
- -
{$detail.content|raw}
-
- -
{$detail.content|raw}
-
- -
-
- 评论 -
- 张三: -

12sdfksdljfksdljdksf是看大家分厘卡聖誕節分厘卡聖誕節付款了

-
-
- 张三: -

12sdfksdljfksdljdksf是看大家分厘卡聖誕節分厘卡聖誕節付款了

-
-
- 张三: -

12sdfksdljfksdljdksf是看大家分厘卡聖誕節分厘卡聖誕節付款了

-
-
-
- -
-
- {notempty name="share_config"} -
-

{:lang_i18n('分享')}

- -
- {/notempty} -
-

{:lang_i18n('留言')}

-
- {:lang_i18n('名称')} - - {:lang_i18n('电子邮箱')} - -

{:lang_i18n('您的电子邮件地址不会被公开')}

- {:lang_i18n('留言内容')} - -
{:lang_i18n('提交留言')}
-
-
-
- - {notempty name="$recommends"} -
- -
-
-

{:lang_i18n('你可能还喜欢')}

-

-
- -
-
- {/notempty} + +
+
+
+

{$detail.title}

+

{$detail.release_time}

+
+ +
{$detail.content|raw}
+
+ +
{$detail.content|raw}
+
+ {notempty name="comments"} +
+
+ {:lang_i18n('评论')} + {volist name="comments" id="cm"} +
+ {$cm.name}: +

{$cm.content}

+
+ {/volist} +
+
+ {/notempty} + +
+ {notempty name="share_config"} +
+

{:lang_i18n('分享')}

+ +
+ {/notempty} +
+

{:lang_i18n('留言')}

+
+ {:lang_i18n('名称')} + + {:lang_i18n('电子邮箱')} + +

{:lang_i18n('您的电子邮件地址不会被公开')}

+ {:lang_i18n('留言内容')} + +
{:lang_i18n('提交留言')}
+
+
+
+ +{notempty name="$recommends"} +
+ +
+
+

{:lang_i18n('你可能还喜欢')}

+

+
+ +
+
+{/notempty} {/block} {block name="script"} {/block} \ No newline at end of file