正在显示
5 个修改的文件
包含
76 行增加
和
28 行删除
@@ -26,7 +26,7 @@ class ArticleController extends HomeBaseController | @@ -26,7 +26,7 @@ class ArticleController extends HomeBaseController | ||
26 | 26 | ||
27 | $articleId = $this->request->param('id', 0, 'intval'); | 27 | $articleId = $this->request->param('id', 0, 'intval'); |
28 | $categoryId = $this->request->param('cid', 0, 'intval'); | 28 | $categoryId = $this->request->param('cid', 0, 'intval'); |
29 | - $article = $postService->publishedArticle($articleId, $categoryId); | 29 | + $article = $postService->publishedArticleJYHT($articleId, $categoryId); |
30 | 30 | ||
31 | if (empty($articleId)) { | 31 | if (empty($articleId)) { |
32 | abort(404, '文章不存在!'); | 32 | abort(404, '文章不存在!'); |
@@ -30,7 +30,7 @@ class PortalPostModel extends Model | @@ -30,7 +30,7 @@ class PortalPostModel extends Model | ||
30 | */ | 30 | */ |
31 | public function user() | 31 | public function user() |
32 | { | 32 | { |
33 | - return $this->belongsTo('UserModel', 'user_id')->setEagerlyType(1); | 33 | + return $this->belongsTo('UserModel', 'author_id')->setEagerlyType(1); |
34 | } | 34 | } |
35 | 35 | ||
36 | /** | 36 | /** |
@@ -34,7 +34,7 @@ class PostService | @@ -34,7 +34,7 @@ class PostService | ||
34 | ]; | 34 | ]; |
35 | 35 | ||
36 | $join = [ | 36 | $join = [ |
37 | - ['__USER__ u', 'a.user_id = u.id'] | 37 | + ['__USER__ u', 'a.author_id = u.id'] |
38 | ]; | 38 | ]; |
39 | 39 | ||
40 | $field = 'a.*,u.user_login,u.user_nickname,u.user_email'; | 40 | $field = 'a.*,u.user_login,u.user_nickname,u.user_email'; |
@@ -122,6 +122,45 @@ class PostService | @@ -122,6 +122,45 @@ class PostService | ||
122 | 122 | ||
123 | return $article; | 123 | return $article; |
124 | } | 124 | } |
125 | + public function publishedArticleJYHT($postId, $categoryId = 0) | ||
126 | + { | ||
127 | + $portalPostModel = new PortalPostModel(); | ||
128 | + | ||
129 | + if (empty($categoryId)) { | ||
130 | + | ||
131 | + $where = [ | ||
132 | + 'post.post_type' => 1, | ||
133 | + 'post.published_time' => [['< time', time()], ['> time', 0]], | ||
134 | + 'post.post_status' => 1, | ||
135 | + 'post.delete_time' => 0, | ||
136 | + 'post.id' => $postId | ||
137 | + ]; | ||
138 | + | ||
139 | + $article = $portalPostModel->alias('post')->field('post.*') | ||
140 | + ->where($where) | ||
141 | + ->find(); | ||
142 | + } else { | ||
143 | + $where = [ | ||
144 | + 'post.post_type' => 1, | ||
145 | + 'post.published_time' => [['< time', time()], ['> time', 0]], | ||
146 | + 'post.post_status' => 1, | ||
147 | + 'post.delete_time' => 0, | ||
148 | + 'relation.category_id' => $categoryId, | ||
149 | + 'relation.post_id' => $postId | ||
150 | + ]; | ||
151 | + | ||
152 | + $join = [ | ||
153 | + ['__PORTAL_CATEGORY_POST__ relation', 'post.id = relation.post_id'] | ||
154 | + ]; | ||
155 | + $article = $portalPostModel->alias('post')->field('post.*') | ||
156 | + ->join($join) | ||
157 | + ->where($where) | ||
158 | + ->find(); | ||
159 | + } | ||
160 | + | ||
161 | + | ||
162 | + return $article; | ||
163 | + } | ||
125 | 164 | ||
126 | //上一篇文章 | 165 | //上一篇文章 |
127 | public function publishedPrevArticle($postId, $categoryId = 0) | 166 | public function publishedPrevArticle($postId, $categoryId = 0) |
@@ -18,13 +18,44 @@ | @@ -18,13 +18,44 @@ | ||
18 | <div class="article_item"> | 18 | <div class="article_item"> |
19 | <div class="article_title">{$article.post_title}</div> | 19 | <div class="article_title">{$article.post_title}</div> |
20 | <div class="article_info"> | 20 | <div class="article_info"> |
21 | - <text>{$article.user.user_nickname}</text> | ||
22 | - <text>2018.08.21</text> | 21 | + <text>{$article.user.user_login}</text> |
22 | + <text>{:date('Y.m.d',$article.published_time)}</text> | ||
23 | </div> | 23 | </div> |
24 | <div> | 24 | <div> |
25 | {$article.post_content} | 25 | {$article.post_content} |
26 | </div> | 26 | </div> |
27 | </div> | 27 | </div> |
28 | + <php> | ||
29 | + $after_content_hook_param=[ | ||
30 | + 'object_id'=>$article['id'], | ||
31 | + 'table_name'=>'portal_post', | ||
32 | + 'object_title'=>$article['post_title'], | ||
33 | + 'user_id'=>$article['user_id'], | ||
34 | + 'url'=>cmf_url_encode('portal/Article/index',array('id'=>$article['id'],'cid'=>$category['id'])), | ||
35 | + 'object'=>$article | ||
36 | + ]; | ||
37 | + </php> | ||
38 | + <hook name="after_content" param="after_content_hook_param"/> | ||
39 | + <php> | ||
40 | + $comment_hook_param=[ | ||
41 | + 'object_id'=>$article['id'], | ||
42 | + 'table_name'=>'portal_post', | ||
43 | + 'full_name'=>'portal_post', | ||
44 | + 'object_title'=>$article['post_title'], | ||
45 | + 'url'=>cmf_url_encode('portal/Article/index',array('id'=>$article['id'],'cid'=>$category['id'])) | ||
46 | + ]; | ||
47 | + $comment=hook_one('comment',$comment_hook_param); | ||
48 | + </php> | ||
49 | + | ||
50 | + <if condition="empty($comment) && cmf_get_current_admin_id()"> | ||
51 | + <div style="border: 1px dashed #ddd;min-height: 200px;padding-top: 50px;"> | ||
52 | + <div class="alert alert-warning" role="alert"> | ||
53 | + 此区域这为评论区,请安装评论插件!<br> | ||
54 | + <em>注:普通用户不会看到此提示!</em> | ||
55 | + </div> | ||
56 | + </div> | ||
57 | + </if> | ||
58 | + {$comment} | ||
28 | <div class="article_item"> | 59 | <div class="article_item"> |
29 | <div> | 60 | <div> |
30 | <text class="content_title">最新活动</text> | 61 | <text class="content_title">最新活动</text> |
@@ -48,28 +79,6 @@ | @@ -48,28 +79,6 @@ | ||
48 | </div> | 79 | </div> |
49 | </div> | 80 | </div> |
50 | <!-- dibu--> | 81 | <!-- dibu--> |
51 | -<div class="null_box"></div> | ||
52 | -<div class="bottom_box"> | ||
53 | - <textarea placeholder="写评论..." maxlength="200"></textarea> | ||
54 | - <div class="submit_btn"> | ||
55 | - <text class="iconfont icon-tijiao"></text> | ||
56 | - <text>提交</text> | ||
57 | - </div> | ||
58 | -</div> | ||
59 | -<!--弹窗--> | ||
60 | -<div class="public_popup_box"> | ||
61 | - <text>您已签到成功!</text> | ||
62 | - <text>恭喜您获得10个积分</text> | ||
63 | -</div> | ||
64 | 82 | ||
65 | -<script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script> | ||
66 | -<script src="__TMPL__/public/assets/js/area.js"></script> | ||
67 | -<script src="__TMPL__/public/assets/js/select.js"></script> | ||
68 | -<script> | ||
69 | - $('.public_popup_box').hide() | ||
70 | - $('.submit_btn').click(function () { | ||
71 | - $('.public_popup_box').show().delay(2000).hide(2) | ||
72 | - }) | ||
73 | -</script> | ||
74 | </body> | 83 | </body> |
75 | </html> | 84 | </html> |
@@ -3,7 +3,7 @@ body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, fo | @@ -3,7 +3,7 @@ body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, fo | ||
3 | padding: 0; | 3 | padding: 0; |
4 | } | 4 | } |
5 | body,html{ | 5 | body,html{ |
6 | - overflow: hidden; | 6 | + /* overflow: hidden;*/ |
7 | } | 7 | } |
8 | 8 | ||
9 | body, button, input, select, textarea { | 9 | body, button, input, select, textarea { |
-
请 注册 或 登录 后发表评论