文章优化、支持分类、支持小程序
parent
dcf49be56c
commit
d98369d7fd
|
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( https://opensource.org/licenses/mit-license.php )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Devil
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\service\ApiService;
|
||||
use app\service\SystemBaseService;
|
||||
use app\service\ArticleService;
|
||||
|
||||
/**
|
||||
* 文章
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-08
|
||||
* @desc description
|
||||
*/
|
||||
class Article extends Common
|
||||
{
|
||||
/**
|
||||
* 构造方法
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-08
|
||||
* @desc description
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// 调用父类前置方法
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-08
|
||||
* @desc description
|
||||
*/
|
||||
public function Index()
|
||||
{
|
||||
// 获取分类
|
||||
$article_category = ArticleService::ArticleCategoryList();
|
||||
|
||||
// 返回数据
|
||||
$result = [
|
||||
'category_list' => $article_category['data'],
|
||||
];
|
||||
return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类文章列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-08
|
||||
* @desc description
|
||||
*/
|
||||
public function DataList()
|
||||
{
|
||||
// 参数
|
||||
$params = $this->data_post;
|
||||
|
||||
// 分页
|
||||
$number = 10;
|
||||
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
|
||||
|
||||
// 条件
|
||||
$where = ArticleService::ArticleWhere($params);
|
||||
|
||||
// 获取总数
|
||||
$total = ArticleService::ArticleTotal($where);
|
||||
$page_total = ceil($total/$number);
|
||||
$start = intval(($page-1)*$number);
|
||||
|
||||
// 获取列表
|
||||
$data_params = [
|
||||
'm' => $start,
|
||||
'n' => $number,
|
||||
'where' => $where,
|
||||
];
|
||||
$data = ArticleService::ArticleList($data_params);
|
||||
|
||||
// 返回数据
|
||||
$result = [
|
||||
'total' => $total,
|
||||
'page_total' => $page_total,
|
||||
'data' => $data['data'],
|
||||
];
|
||||
return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章详情
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-08
|
||||
* @desc description
|
||||
*/
|
||||
public function Detail()
|
||||
{
|
||||
// 获取文章
|
||||
if(!empty($this->data_request['id']))
|
||||
{
|
||||
// 获取数据
|
||||
$id = intval($this->data_request['id']);
|
||||
$params = [
|
||||
'where' => [
|
||||
'is_enable' => 1,
|
||||
'id' => $id,
|
||||
],
|
||||
'field' => 'id,title,title_color,jump_url,content,access_count,article_category_id,seo_title,seo_keywords,seo_desc,add_time',
|
||||
'm' => 0,
|
||||
'n' => 1,
|
||||
];
|
||||
$data = ArticleService::ArticleList($params);
|
||||
if(!empty($data['data'][0]))
|
||||
{
|
||||
// 访问统计
|
||||
ArticleService::ArticleAccessCountInc(['id'=>$id]);
|
||||
|
||||
// 返回数据
|
||||
$result = [
|
||||
'data' => $data['data'][0],
|
||||
'category_list' => $article_category['data'],
|
||||
];
|
||||
$ret = SystemBaseService::DataReturn($result);
|
||||
} else {
|
||||
$ret = DataReturn('文章不存在或已删除', -1);
|
||||
}
|
||||
} else {
|
||||
$ret = DataReturn('文章ID有误', -1);
|
||||
}
|
||||
return ApiService::ApiDataReturn($ret);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -36,11 +36,12 @@ class Article extends Common
|
|||
}
|
||||
|
||||
/**
|
||||
* [Index 文章详情]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-06T21:31:53+0800
|
||||
* 文章详情
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-08
|
||||
* @desc description
|
||||
*/
|
||||
public function Index()
|
||||
{
|
||||
|
|
@ -77,8 +78,11 @@ class Article extends Common
|
|||
}
|
||||
|
||||
// 获取分类
|
||||
$article_category_content = ArticleService::ArticleCategoryListContent();
|
||||
MyViewAssign('category_list', $article_category_content['data']);
|
||||
$article_category = ArticleService::ArticleCategoryList();
|
||||
MyViewAssign('category_list', $article_category['data']);
|
||||
|
||||
// 上一篇、下一篇
|
||||
MyViewAssign('last_next_data', ArticleService::ArticleLastNextData($id));
|
||||
|
||||
// seo
|
||||
$seo_title = empty($article['seo_title']) ? $article['title'] : $article['seo_title'];
|
||||
|
|
@ -93,7 +97,7 @@ class Article extends Common
|
|||
}
|
||||
|
||||
// 钩子
|
||||
$this->PluginsHook($id, $article);
|
||||
$this->PluginsContentHook($id, $article);
|
||||
|
||||
MyViewAssign('article', $article);
|
||||
return MyView();
|
||||
|
|
@ -105,7 +109,104 @@ class Article extends Common
|
|||
}
|
||||
|
||||
/**
|
||||
* 钩子处理
|
||||
* 文章分类
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-08
|
||||
* @desc description
|
||||
*/
|
||||
public function Category()
|
||||
{
|
||||
// 条件
|
||||
$where = ArticleService::ArticleWhere($this->data_request);
|
||||
|
||||
// 总数
|
||||
$total = ArticleService::ArticleTotal($where);
|
||||
|
||||
// 分页
|
||||
$page_params = [
|
||||
'number' => $this->page_size,
|
||||
'total' => $total,
|
||||
'where' => $this->data_request,
|
||||
'page' => $this->page,
|
||||
'url' => MyUrl('index/article/category'),
|
||||
];
|
||||
$page = new \base\Page($page_params);
|
||||
|
||||
// 获取列表
|
||||
$data_params = [
|
||||
'm' => $page->GetPageStarNumber(),
|
||||
'n' => $this->page_size,
|
||||
'where' => $where,
|
||||
];
|
||||
$ret = ArticleService::ArticleList($data_params);
|
||||
|
||||
// 获取分类
|
||||
$article_category = ArticleService::ArticleCategoryList();
|
||||
MyViewAssign('category_list', $article_category['data']);
|
||||
|
||||
// 分类信息
|
||||
$category_info = ArticleService::ArticleCategoryInfo($this->data_request, $article_category['data']);
|
||||
MyViewAssign('category_info', $category_info);
|
||||
|
||||
// 浏览器名称
|
||||
MyViewAssign('home_seo_site_title', SeoService::BrowserSeoTitle(empty($category_info) ? '所有文章' : $category_info['name'], 1));
|
||||
|
||||
// 基础参数赋值
|
||||
MyViewAssign('page_html', $page->GetPageHtml());
|
||||
MyViewAssign('data_list', $ret['data']);
|
||||
MyViewAssign('params', $this->data_request);
|
||||
|
||||
// 钩子
|
||||
$this->PluginsCategoryHook($ret['data'], $this->data_request);
|
||||
return MyView();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类钩子处理
|
||||
* @author whats
|
||||
* @version 1.0.0
|
||||
* @date 2019-04-22
|
||||
* @desc description
|
||||
* @param [array] $data [文章内容]
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
private function PluginsCategoryHook(&$data, $params = [])
|
||||
{
|
||||
$hook_arr = [
|
||||
// 分类内容顶部钩子
|
||||
'plugins_view_article_category_top',
|
||||
|
||||
// 分类底部钩子
|
||||
'plugins_view_article_category_bottom',
|
||||
|
||||
// 分类内容顶部钩子
|
||||
'plugins_view_article_category_content_top',
|
||||
|
||||
// 分类内容底部钩子
|
||||
'plugins_view_article_category_content_botton',
|
||||
|
||||
// 分类左侧内部顶部钩子
|
||||
'plugins_view_article_category_left_inside_top',
|
||||
|
||||
// 分类左侧内部底部钩子
|
||||
'plugins_view_article_category_left_inside_botton',
|
||||
];
|
||||
foreach($hook_arr as $hook_name)
|
||||
{
|
||||
MyViewAssign($hook_name.'_data', MyEventTrigger($hook_name,
|
||||
[
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => false,
|
||||
'data' => &$data,
|
||||
'params' => $params,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 内容钩子处理
|
||||
* @author whats
|
||||
* @version 1.0.0
|
||||
* @date 2019-04-22
|
||||
|
|
@ -113,7 +214,7 @@ class Article extends Common
|
|||
* @param [int] $article_id [文章id]
|
||||
* @param [array] $article [文章内容]
|
||||
*/
|
||||
private function PluginsHook($article_id, &$article)
|
||||
private function PluginsContentHook($article_id, &$article)
|
||||
{
|
||||
$hook_arr = [
|
||||
// 文章内容顶部钩子
|
||||
|
|
|
|||
|
|
@ -0,0 +1,165 @@
|
|||
{{include file="public/header" /}}
|
||||
|
||||
<!-- header top nav -->
|
||||
{{include file="public/header_top_nav" /}}
|
||||
|
||||
<!-- search -->
|
||||
{{include file="public/nav_search" /}}
|
||||
|
||||
<!-- header nav -->
|
||||
{{include file="public/header_nav" /}}
|
||||
|
||||
<!-- goods category -->
|
||||
{{include file="public/goods_category" /}}
|
||||
|
||||
<!-- 文章分类顶部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_article_category_top</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_article_category_top_data) and is_array($plugins_view_article_category_top_data)}}
|
||||
{{foreach $plugins_view_article_category_top_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<!-- content start -->
|
||||
<div class="am-container article-content am-padding-sm">
|
||||
<!-- 右侧内容 -->
|
||||
<div class="am-u-md-10 am-u-md-push-2 article-right">
|
||||
{{if !empty($category_info)}}
|
||||
<div class="article-header am-text-center am-padding-0">
|
||||
<h1 class="am-article-title">{{$category_info.name}}</h1>
|
||||
<hr class="am-article-divider" />
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<!-- 文章分类内容底部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_article_category_content_top</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_article_category_content_top_data) and is_array($plugins_view_article_category_content_top_data)}}
|
||||
{{foreach $plugins_view_article_category_content_top_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<!-- 内容 -->
|
||||
{{if !empty($data_list)}}
|
||||
<div data-am-widget="list_news" class="am-list-news am-list-news-default am-margin-0">
|
||||
<div class="am-list-news-bd">
|
||||
<ul class="am-list category-content-list">
|
||||
{{foreach $data_list as $v}}
|
||||
<li class="am-g am-list-item-dated">
|
||||
<a href="{{$v.url}}" class="am-list-item-hd" {{if !empty($v['title_color'])}}style="color:{{$v.title_color}};"{{/if}}>{{$v.title}}</a>
|
||||
<span class="am-list-date">{{$v.add_time}}</span>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="am-padding-top-sm">{{$page_html|raw}}</div>
|
||||
{{else /}}
|
||||
{{include file="public/not_data" /}}
|
||||
{{/if}}
|
||||
|
||||
<!-- 文章分类内容底部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_article_category_content_botton</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_article_category_content_botton_data) and is_array($plugins_view_article_category_content_botton_data)}}
|
||||
{{foreach $plugins_view_article_category_content_botton_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<!-- 左侧内容 -->
|
||||
<div class="am-u-md-2 am-u-md-pull-10 article-sidebar am-padding-0">
|
||||
<div class="am-offcanvas" id="article-nav-sidebar">
|
||||
<div class="am-offcanvas-bar am-offcanvas-bar-overlay">
|
||||
<!-- 左侧内部顶部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_article_category_left_inside_top</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_article_category_left_inside_top_data) and is_array($plugins_view_article_category_left_inside_top_data)}}
|
||||
{{foreach $plugins_view_article_category_left_inside_top_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<!-- 左侧内容 -->
|
||||
{{if !empty($category_list)}}
|
||||
<section data-am-widget="accordion" class="am-accordion am-accordion-gapped am-padding-0" data-am-accordion='{}'>
|
||||
<!-- 分类 -->
|
||||
<div class="am-panel am-panel-default am-panel-group am-margin-bottom-0">
|
||||
<div class="am-panel-hd am-padding-left-sm">
|
||||
<h3 class="am-panel-title">文章分类</h3>
|
||||
</div>
|
||||
<ul class="am-nav category-list">
|
||||
{{foreach $category_list as $v}}
|
||||
<li>
|
||||
<a href="{{$v.url}}" title="{{$v.name}}" {{if isset($params['id']) and $params['id'] eq $v['id']}}class="am-active"{{/if}}>{{$v.name}}</a>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
<!-- 左侧内部底部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_article_category_left_inside_botton</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_article_category_left_inside_botton_data) and is_array($plugins_view_article_category_left_inside_botton_data)}}
|
||||
{{foreach $plugins_view_article_category_left_inside_botton_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a href="javascript:;" class="am-icon-btn am-icon-th-list am-show-sm-only article-nav-button" data-am-offcanvas="{target: '#article-nav-sidebar'}">
|
||||
<span class="am-sr-only">侧栏导航</span>
|
||||
</a>
|
||||
</div>
|
||||
<!-- content end -->
|
||||
|
||||
<!-- 文章分类底部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_article_category_bottom</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if !empty($plugins_view_article_category_bottom_data) and is_array($plugins_view_article_category_bottom_data)}}
|
||||
{{foreach $plugins_view_article_category_bottom_data as $hook}}
|
||||
{{if is_string($hook) or is_int($hook)}}
|
||||
{{$hook|raw}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<!-- footer start -->
|
||||
{{include file="public/footer" /}}
|
||||
<!-- footer end -->
|
||||
|
|
@ -27,10 +27,10 @@
|
|||
{{/if}}
|
||||
|
||||
<!-- content start -->
|
||||
<div class="am-container article-content">
|
||||
<div class="am-container article-content am-padding-sm">
|
||||
<!-- 右侧内容 -->
|
||||
<div class="am-u-md-10 am-u-md-push-2 article-right">
|
||||
<div class="am-u-sm-12 article-header">
|
||||
<div class="article-header am-text-center am-padding-0">
|
||||
<h1 class="am-article-title">{{$article.title}}</h1>
|
||||
<p class="am-article-meta">
|
||||
<span>发布时间:{{$article.add_time}}</span>
|
||||
|
|
@ -56,6 +56,31 @@
|
|||
<!-- 文章内容 -->
|
||||
<div class="am-article am-scrollable-horizontal">{{$article.content|raw}}</div>
|
||||
|
||||
<!-- 上一条、下一条 -->
|
||||
<div class="last-next-data am-margin-top-lg am-padding-bottom-sm">
|
||||
<hr class="am-article-divider am-margin-bottom-sm" />
|
||||
<div class="am-nbfc am-padding-horizontal-sm">
|
||||
<div class="am-fl">
|
||||
<span>上一篇:</span>
|
||||
{{if !empty($last_next_data['last'])}}
|
||||
<a href="{{$last_next_data.last.url}}" class="am-text-primary">{{$last_next_data.last.title}}</a>
|
||||
<span class="text-tips am-margin-left-sm">{{$last_next_data.last.add_time}}</span>
|
||||
{{else /}}
|
||||
<span class="text-tips">没有符合条件的文章</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="am-fr">
|
||||
<span>下一篇:</span>
|
||||
{{if !empty($last_next_data['next'])}}
|
||||
<a href="{{$last_next_data.next.url}}" class="am-text-primary">{{$last_next_data.next.title}}</a>
|
||||
<span class="text-tips am-margin-left-sm">{{$last_next_data.next.add_time}}</span>
|
||||
{{else /}}
|
||||
<span class="text-tips">没有符合条件的文章</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 文章内容底部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
|
|
@ -72,10 +97,10 @@
|
|||
</div>
|
||||
|
||||
<!-- 左侧内容 -->
|
||||
<div class="am-u-md-2 am-u-md-pull-10 article-sidebar">
|
||||
<div class="am-u-md-2 am-u-md-pull-10 article-sidebar am-padding-0">
|
||||
<div class="am-offcanvas" id="article-nav-sidebar">
|
||||
<div class="am-offcanvas-bar am-offcanvas-bar-overlay">
|
||||
<!-- 文章左侧内部顶部钩子 -->
|
||||
<!-- 左侧内部顶部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_article_detail_left_inside_top</span>
|
||||
|
|
@ -89,33 +114,26 @@
|
|||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
<!-- 文章左侧内容 -->
|
||||
<!-- 左侧内容 -->
|
||||
{{if !empty($category_list)}}
|
||||
<section data-am-widget="accordion" class="am-accordion am-accordion-gapped" data-am-accordion='{}'>
|
||||
{{foreach $category_list as $v}}
|
||||
<dl class="am-accordion-item {{if $article['article_category_id'] eq $v['id']}}am-active{{/if}}">
|
||||
<dt class="am-accordion-title">
|
||||
<li class="am-nav-header">{{$v.name}}</li>
|
||||
</dt>
|
||||
<dd class="am-accordion-bd am-collapse {{if $article['article_category_id'] eq $v['id']}}am-in{{/if}}">
|
||||
<div class="am-accordion-content">
|
||||
{{if !empty($v.items)}}
|
||||
<ul class="am-nav">
|
||||
{{foreach $v.items as $vs}}
|
||||
<li>
|
||||
<a href="{{$vs.url}}" {{if !empty($vs.title_color)}}style="color:{{$vs.title_color}};"{{/if}} >{{$vs.title}}</a>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
{{/foreach}}
|
||||
<section data-am-widget="accordion" class="am-accordion am-accordion-gapped am-padding-0" data-am-accordion='{}'>
|
||||
<!-- 分类 -->
|
||||
<div class="am-panel am-panel-default am-panel-group am-margin-bottom-0">
|
||||
<div class="am-panel-hd am-padding-left-sm">
|
||||
<h3 class="am-panel-title">文章分类</h3>
|
||||
</div>
|
||||
<ul class="am-nav category-list">
|
||||
{{foreach $category_list as $v}}
|
||||
<li>
|
||||
<a href="{{$v.url}}" title="{{$v.name}}" {{if isset($article['article_category_id']) and $article['article_category_id'] eq $v['id']}}class="am-active"{{/if}}>{{$v.name}}</a>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
<!-- 文章左侧内部底部钩子 -->
|
||||
<!-- 左侧内部底部钩子 -->
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<div class="plugins-tag">
|
||||
<span>plugins_view_article_detail_left_inside_botton</span>
|
||||
|
|
|
|||
|
|
@ -82,12 +82,10 @@
|
|||
<ul>
|
||||
{{foreach $article_list as $article}}
|
||||
<li class="am-text-truncate">
|
||||
<a href="{{$article.url}}" target="_blank">
|
||||
{{if isset($article['article_category_name'])}}
|
||||
<span>[</span><p class="news-category-name am-inline-block am-text-truncate">{{$article.article_category_name}}</p><span>]</span>
|
||||
{{/if}}
|
||||
<span {{if !empty($article.title_color)}}style="color:{{$article.title_color}};"{{/if}} >{{$article.title}}</span>
|
||||
</a>
|
||||
{{if isset($article['article_category_name']) and isset($article['category_url'])}}
|
||||
<span>[</span><a href="{{$article.category_url}}" target="_blank"><p class="news-category-name am-inline-block am-text-truncate">{{$article.article_category_name}}</p></a><span>]</span>
|
||||
{{/if}}
|
||||
<a href="{{$article.url}}" target="_blank" {{if !empty($article.title_color)}}style="color:{{$article.title_color}};"{{/if}}>{{$article.title}}</a>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
{{/if}}
|
||||
{{/if}}
|
||||
{{if !empty($v['tips'])}}
|
||||
<p class="am-text-xs am-margin-bottom-xs cr-999">{{$v.tips}}</p>
|
||||
<p class="am-text-xs am-margin-bottom-xs">{{$v.tips}}</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{if empty($data[$v['type']]) and empty($v['msg'])}}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ Route::rule('buy', 'index/buy/index', 'GET|POST');
|
|||
Route::post('buy-add', 'index/buy/add');
|
||||
|
||||
// 文章
|
||||
Route::get('article-category'.$ds.'[:id]', 'index/article/category');
|
||||
Route::get('article'.$ds.':id', 'index/article/index');
|
||||
|
||||
// 页面设计
|
||||
|
|
|
|||
|
|
@ -72,18 +72,41 @@ class ArticleService
|
|||
$n = isset($params['n']) ? intval($params['n']) : 10;
|
||||
|
||||
$data = Db::name('Article')->field($field)->where($where)->order($order_by)->limit($m, $n)->select()->toArray();
|
||||
return DataReturn('处理成功', 0, self::DataHandle($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据处理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-09
|
||||
* @desc description
|
||||
* @param [array] $data [文章数据]
|
||||
*/
|
||||
public static function DataHandle($data)
|
||||
{
|
||||
if(!empty($data))
|
||||
{
|
||||
$category_names = Db::name('ArticleCategory')->where(['id'=>array_column($data, 'article_category_id')])->column('name', 'id');
|
||||
// 字段列表
|
||||
$keys = ArrayKeys($data);
|
||||
|
||||
// 分类名称
|
||||
if(in_array('article_category_id', $keys))
|
||||
{
|
||||
$category_names = Db::name('ArticleCategory')->where(['id'=>array_column($data, 'article_category_id')])->column('name', 'id');
|
||||
}
|
||||
|
||||
foreach($data as &$v)
|
||||
{
|
||||
// url
|
||||
$v['url'] = MyUrl('index/article/index', ['id'=>$v['id']]);
|
||||
$v['url'] = (APPLICATION == 'web') ? MyUrl('index/article/index', ['id'=>$v['id']]) : '/pages/article-detail/article-detail?id='.$v['id'];
|
||||
|
||||
// 分类名称
|
||||
if(isset($v['article_category_id']))
|
||||
{
|
||||
$v['article_category_name'] = isset($category_names[$v['article_category_id']]) ? $category_names[$v['article_category_id']] : '';
|
||||
$v['article_category_name'] = (!empty($category_names) && isset($category_names[$v['article_category_id']])) ? $category_names[$v['article_category_id']] : '';
|
||||
$v['category_url'] = (APPLICATION == 'web') ? MyUrl('index/article/category', ['id'=>$v['article_category_id']]) : '/pages/article-category/article-category?id='.$v['article_category_id'];
|
||||
}
|
||||
|
||||
// 内容
|
||||
|
|
@ -117,7 +140,7 @@ class ArticleService
|
|||
}
|
||||
}
|
||||
}
|
||||
return DataReturn('处理成功', 0, $data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -133,6 +156,31 @@ class ArticleService
|
|||
return (int) Db::name('Article')->where($where)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-08
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function ArticleWhere($params = [])
|
||||
{
|
||||
// 默认条件
|
||||
$where = [
|
||||
['is_enable', '=', 1],
|
||||
];
|
||||
|
||||
// 分类id
|
||||
if(!empty($params['id']))
|
||||
{
|
||||
$where[] = ['article_category_id', '=', intval($params['id'])];
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章保存
|
||||
* @author Devil
|
||||
|
|
@ -250,37 +298,6 @@ class ArticleService
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类和所有文章
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-10-19
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function ArticleCategoryListContent($params = [])
|
||||
{
|
||||
$data = Db::name('ArticleCategory')->field('id,name')->where(['is_enable'=>1])->order('id asc, sort asc')->select()->toArray();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$items = Db::name('Article')->field('id,title,title_color')->where(['article_category_id'=>$v['id'], 'is_enable'=>1])->select()->toArray();
|
||||
if(!empty($items))
|
||||
{
|
||||
foreach($items as &$vs)
|
||||
{
|
||||
// url
|
||||
$vs['url'] = MyUrl('index/article/index', ['id'=>$vs['id']]);
|
||||
}
|
||||
}
|
||||
$v['items'] = $items;
|
||||
}
|
||||
}
|
||||
return DataReturn('处理成功', 0, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章访问统计加1
|
||||
* @author Devil
|
||||
|
|
@ -312,10 +329,58 @@ class ArticleService
|
|||
{
|
||||
$field = empty($params['field']) ? '*' : $params['field'];
|
||||
$order_by = empty($params['order_by']) ? 'sort asc' : trim($params['order_by']);
|
||||
|
||||
$data = Db::name('ArticleCategory')->where(['is_enable'=>1])->field($field)->order($order_by)->select()->toArray();
|
||||
|
||||
return DataReturn('处理成功', 0, $data);
|
||||
return DataReturn('处理成功', 0, self::CategoryDataHandle($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类处理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-08
|
||||
* @desc description
|
||||
* @param [array] $data [分类数据]
|
||||
*/
|
||||
public static function CategoryDataHandle($data)
|
||||
{
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['url'] = (APPLICATION == 'web') ? MyUrl('index/article/category', ['id'=>$v['id']]) : '/pages/article-category/article-category?id='.$v['id'];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类信息
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-08
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
* @param [array] $data [指定分类数据列表]
|
||||
*/
|
||||
public static function ArticleCategoryInfo($params = [], $data = [])
|
||||
{
|
||||
// 数据不存在则读取
|
||||
if(!empty($params['id']))
|
||||
{
|
||||
if(empty($data))
|
||||
{
|
||||
$data = Db::name('ArticleCategory')->where(['is_enable'=>1,'id'=>intval($params['id'])])->field('*')->order('sort asc')->select()->toArray();
|
||||
} else {
|
||||
$temp = array_column($data, null, 'id');
|
||||
$data = array_key_exists($params['id'], $temp) ? [$temp[$params['id']]] : [];
|
||||
}
|
||||
} else {
|
||||
$data = [];
|
||||
}
|
||||
$data = self::CategoryDataHandle($data);
|
||||
return (empty($data) || empty($data[0])) ? null : $data[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -511,5 +576,39 @@ class ArticleService
|
|||
}
|
||||
return DataReturn('删除失败', -100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上一篇、下一篇数据
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2021-11-09
|
||||
* @desc description
|
||||
* @param [int] $article_id [文章id]
|
||||
*/
|
||||
public static function ArticleLastNextData($article_id)
|
||||
{
|
||||
// 指定字段
|
||||
$field = 'id,title,add_time';
|
||||
|
||||
// 上一条数据
|
||||
$where = [
|
||||
['is_enable', '=', 1],
|
||||
['id', '<', $article_id],
|
||||
];
|
||||
$last = self::DataHandle(Db::name('Article')->where($where)->field($field)->order('id desc')->limit(1)->select()->toArray());
|
||||
|
||||
// 上一条数据
|
||||
$where = [
|
||||
['is_enable', '=', 1],
|
||||
['id', '>', $article_id],
|
||||
];
|
||||
$next = self::DataHandle(Db::name('Article')->where($where)->field($field)->order('id asc')->limit(1)->select()->toArray());
|
||||
|
||||
return [
|
||||
'last' => empty($last) ? [] : $last[0],
|
||||
'next' => empty($next) ? [] : $next[0],
|
||||
];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,35 +1,100 @@
|
|||
.article-sidebar, .article-header, .am-accordion-gapped .am-accordion-title{padding: 0;}
|
||||
.article-content{padding-top: 10px;}
|
||||
.article-header{text-align: center;}
|
||||
.article-header .am-article-divider{margin: 10px 0 20px 0;}
|
||||
.article-header .am-article-meta{margin-top: 5px;}
|
||||
.article-header .am-article-meta span:not(:first-child){margin-left: 15px;}
|
||||
.article-nav-button{position: fixed; z-index: 10; bottom: 70px; right: 10px;-webkit-box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);-moz-box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);}
|
||||
.am-offcanvas-bar:after{background: #eee;}
|
||||
.article-sidebar ul li{margin-top: 0;}
|
||||
.article-sidebar ul li a{font-size: 12px; padding: 5px;}
|
||||
.article-content .am-accordion-content{padding: 5px;}
|
||||
.am-nav-header{padding: 8px 5px 5px 5px; font-weight: 500;}
|
||||
.am-accordion-gapped dl:first-child{margin-top: 0;}
|
||||
.am-accordion-gapped dl:last-child{margin-bottom: 0;}
|
||||
.am-accordion-gapped .am-accordion-title:after{margin-top: -6px;}
|
||||
.am-accordion-gapped .am-accordion-title, .am-accordion-gapped .am-accordion-item, .am-accordion-gapped .am-accordion-item.am-active{border-color: #eee;}
|
||||
.article-content img { max-width: 100%; }
|
||||
|
||||
.article-content img {
|
||||
max-width: 100%;
|
||||
}
|
||||
.article-header .am-article-divider {
|
||||
margin: 15px 0 20px 0;
|
||||
}
|
||||
.article-header .am-article-meta {
|
||||
margin-top: 5px;
|
||||
}
|
||||
.article-header .am-article-meta span:not(:first-child) {
|
||||
margin-left: 15px;
|
||||
}
|
||||
.article-nav-button {
|
||||
position: fixed;
|
||||
z-index: 10;
|
||||
bottom: 70px;
|
||||
right: 10px;
|
||||
-webkit-box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
|
||||
-moz-box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
|
||||
box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.am-offcanvas-bar:after {
|
||||
background: transparent;
|
||||
}
|
||||
.article-sidebar ul li {
|
||||
margin-top: 0;
|
||||
}
|
||||
.article-sidebar ul li a {
|
||||
font-size: 12px;
|
||||
padding: 8px 10px;
|
||||
}
|
||||
.article-sidebar .am-panel,
|
||||
.category-content-list li {
|
||||
border-color: #eee !important;
|
||||
}
|
||||
.article-sidebar .am-panel {
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.category-list li a.am-active {
|
||||
background-color: #eee;
|
||||
color: #d2364c;
|
||||
}
|
||||
.category-content-list li:first-child {
|
||||
border-top: 0;
|
||||
}
|
||||
.last-next-data .text-tips {
|
||||
color: #999;
|
||||
}
|
||||
@media only screen and (min-width: 641px) {
|
||||
.article-sidebar .am-offcanvas{display: block; position: static; background: none;}
|
||||
.article-sidebar .am-offcanvas-bar{position: static; width: auto; background: none; -webkit-transform: translate3d(0, 0, 0); -ms-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0);}
|
||||
.article-sidebar ul li:not(:last-child){border-bottom: 1px solid #f5f5f5;}
|
||||
.am-accordion-gapped{margin: 0 15px 0 0;}
|
||||
.article-sidebar { padding-left: 5px; }
|
||||
.article-sidebar .am-offcanvas {
|
||||
display: block;
|
||||
position: static;
|
||||
background: none;
|
||||
}
|
||||
.article-sidebar .am-offcanvas-bar {
|
||||
position: static;
|
||||
width: auto;
|
||||
background: none;
|
||||
-webkit-transform: translate3d(0, 0, 0);
|
||||
-ms-transform: translate3d(0, 0, 0);
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
.article-sidebar ul li:not(:last-child) {
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
}
|
||||
.am-accordion-gapped {
|
||||
margin: 0 15px 0 0;
|
||||
}
|
||||
.article-sidebar {
|
||||
padding-left: 5px !important;
|
||||
}
|
||||
}
|
||||
@media only screen and (min-width: 1025px) {
|
||||
.article-sidebar { padding-left: 0; }
|
||||
.article-sidebar {
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
}
|
||||
@media only screen and (max-width: 640px) {
|
||||
.article-right{padding: 0 5px;}
|
||||
.article-sidebar .am-offcanvas-bar{background: #f9f9f9;}
|
||||
.article-sidebar ul li:not(:last-child){border-bottom: 1px solid #eee;}
|
||||
.am-accordion-gapped{margin: 0;}
|
||||
.article-sidebar ul li a{padding-left: 20px;}
|
||||
.article-right {
|
||||
padding: 0 5px;
|
||||
}
|
||||
.article-sidebar .am-offcanvas-bar {
|
||||
background: #f9f9f9;
|
||||
}
|
||||
.article-sidebar ul li:not(:last-child) {
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.am-accordion-gapped {
|
||||
margin: 0;
|
||||
}
|
||||
.last-next-data .am-fl,
|
||||
.last-next-data .am-fr {
|
||||
float: none !important;
|
||||
}
|
||||
.last-next-data .am-fr {
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ ul, li, ol {list-style: none;}
|
|||
.banner-mixed{position: relative;border-top:1px solid #F5F5F5 ;border-bottom: 1px #f5f5f5 solid;overflow: hidden;}
|
||||
.banner-news-title{position: absolute;left:10px;padding-right:10px;border-right:1px solid #eee ;}
|
||||
.banner-news li,#banner-news li a{height: 30px;line-height:30px; font-size: 12px;}
|
||||
.banner-news{max-width:1200px; margin:0px auto; overflow:hidden; height:30px;width:100%; text-align:left;color:#fff;}
|
||||
.banner-news{max-width:1200px; margin:0px auto; overflow:hidden; height:30px;width:100%; text-align:left;}
|
||||
.news-category-name { line-height: 11px; max-width: 50px; }
|
||||
.banner-news li {padding:0 10px 0 80px;}
|
||||
.mod-vip{display: none;}
|
||||
|
|
|
|||
Loading…
Reference in New Issue