From 241d5bc846e1e57704bac11b273d7b5400f4770c Mon Sep 17 00:00:00 2001 From: whats <3022194113@qq.com> Date: Tue, 24 Aug 2021 10:38:28 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=96=87=E7=AB=A0=E5=86=85=E5=AE=B9=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=92=A9=E5=AD=90'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Article.php | 33 +++++++++++++++++++++-- app/index/view/default/article/index.html | 13 +++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index c60f27901..60728cf60 100755 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -89,8 +89,9 @@ class Article extends Common { MyViewAssign('home_seo_site_description', $ret['data'][0]['seo_desc']); } - - MyViewAssign('article', $ret['data'][0]); + $article = $ret['data'][0]; + $this->PluginsHook($id, $article); + MyViewAssign('article', $article); return MyView(); } @@ -98,5 +99,33 @@ class Article extends Common MyViewAssign('msg', '文章不存在或已删除'); return MyView('public/tips_error'); } + + /** + * 钩子处理 + * @author whats + * @blog + * @version 1.0.0 + * @date 2019-04-22 + * @desc description + * @param [int] $article_id [文章id] + * @param [array] $params [输入参数] + */ + private function PluginsHook($article_id, &$article) + { + $hook_arr = [ + //文章内容内部钩子 + 'plugins_view_article_detail_content_within', + ]; + foreach($hook_arr as $hook_name) + { + MyViewAssign($hook_name.'_data', MyEventTrigger($hook_name, + [ + 'hook_name' => $hook_name, + 'is_backend' => false, + 'article_id' => $article_id, + 'article' => &$article, + ])); + } + } } ?> \ No newline at end of file diff --git a/app/index/view/default/article/index.html b/app/index/view/default/article/index.html index 42cb32310..6cd012c78 100755 --- a/app/index/view/default/article/index.html +++ b/app/index/view/default/article/index.html @@ -25,6 +25,19 @@
{{$article.content|raw}}
+ + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
+ plugins_view_article_detail_content_within +
+ {{/if}} + {{if !empty($plugins_view_article_detail_content_within_data) and is_array($plugins_view_article_detail_content_within_data)}} + {{foreach $plugins_view_article_detail_content_within_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} + {{/if}}