提交 8bda4cb4 编写于 作者: G gongfuxiang

seo优化

上级 c8c48800
......@@ -52,6 +52,11 @@
<label>内容</label>
<textarea class="am-radius am-validate" name="content" rows="5" minlength="10" maxlength="105000" {{if !IsMobile()}}id="editor-tag" data-url="{{:MyUrl('admin/ueditor/index', ['path_type'=>'article'])}}" placeholder="内容长度最少 10~105000 个字符" {{else /}} placeholder="内容长度最少 10~105000 个字符更多编辑功能请使用电脑访问" {{/if}} data-validation-message="内容长度最少 10~105000 个字符" required>{{if !empty($data)}}{{$data.content}}{{/if}}</textarea>
</div>
<div class="am-alert am-alert-secondary">
{{include file="lib/seo" /}}
</div>
<div class="am-form-group am-form-group-refreshing">
<input type="hidden" name="id" {{if !empty($data)}} value="{{$data.id}}"{{/if}} />
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>
......
......@@ -169,6 +169,15 @@
<dt>访问次数</dt>
<dd>{{$v.access_count}}</dd>
<dt>SEO标题</dt>
<dd>{{$v.seo_title}}</dd>
<dt>SEO关键字</dt>
<dd>{{$v.seo_keywords}}</dd>
<dt>SEO描述</dt>
<dd>{{$v.seo_desc}}</dd>
<dt>创建时间</dt>
<dd>{{$v.add_time}}</dd>
......
......@@ -368,14 +368,7 @@
<!-- seo -->
<div id="goods-nav-seo" class="division-block">
<label class="block nav-detail-title">SEO</label>
<div class="am-form-group">
<label>SEO关键字<span class="am-form-group-label-tips">一般不超过100个字符,多个关键字以半圆角逗号 [ , ] 隔开</span></label>
<input type="text" name="seo_keywords" placeholder="SEO关键字" maxlength="130" data-validation-message="SEO关键字格式 最多130个字符" class="am-radius" {{if !empty($data)}} value="{{$data.seo_keywords}}"{{/if}} />
</div>
<div class="am-form-group">
<label>SEO描述<span class="am-form-group-label-tips">一般不超过200个字符</span></label>
<textarea rows="4" name="seo_desc" maxlength="230" class="am-radius" placeholder="SEO描述" data-validation-message="SEO描述格式 最多230个字符">{{if !empty($data)}}{{$data.seo_desc}}{{/if}}</textarea>
</div>
{{include file="lib/seo" /}}
</div>
<div class="am-form-group am-form-group-refreshing">
......
......@@ -97,6 +97,9 @@
<input type="number" placeholder="顺序" name="sort" min="0" max="255" data-validation-message="顺序 0~255 之间的数值" class="am-radius" value="0" required />
</div>
{{include file="lib/enable" /}}
<div class="am-alert am-alert-secondary">
{{include file="lib/seo" /}}
</div>
<div class="am-form-group am-form-group-refreshing">
<input type="hidden" name="id" />
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>
......@@ -109,7 +112,7 @@
<!-- save win end -->
<!-- list start -->
<div id="tree" class="m-t-15" data-rank="3" data-additional='[{"field":"bg_color", "value":"", "type":"input"}, {"field":"bg_color", "value":"", "type":"css", "tag":"button.colorpicker-submit", "style":"background-color"}, {"field":"icon", "value":"", "type":"input"}, {"field":"icon_url", "value":"{{$attachment_host}}/static/admin/default/images/default-images.jpg", "type":"attr", "tag":"ul.goods-category-icon-images-view li img", "style":"src"}, {"field":"big_images", "value":"", "type":"input"}, {"field":"big_images_url", "value":"{{$attachment_host}}/static/admin/default/images/default-images.jpg", "type":"attr", "tag":"ul.goods-category-big_images-images-view li img", "style":"src"}, {"field":"vice_name", "value":"", "type":"input"}, {"field":"describe", "value":"", "type":"textarea"}, {"field":"is_home_recommended", "value":"0", "type":"input"}]'>
<div id="tree" class="m-t-15" data-rank="3" data-additional='[{"field":"bg_color", "value":"", "type":"input"}, {"field":"bg_color", "value":"", "type":"css", "tag":"button.colorpicker-submit", "style":"background-color"}, {"field":"icon", "value":"", "type":"input"}, {"field":"icon_url", "value":"{{$attachment_host}}/static/admin/default/images/default-images.jpg", "type":"attr", "tag":"ul.goods-category-icon-images-view li img", "style":"src"}, {"field":"big_images", "value":"", "type":"input"}, {"field":"big_images_url", "value":"{{$attachment_host}}/static/admin/default/images/default-images.jpg", "type":"attr", "tag":"ul.goods-category-big_images-images-view li img", "style":"src"}, {"field":"vice_name", "value":"", "type":"input"}, {"field":"describe", "value":"", "type":"textarea"}, {"field":"is_home_recommended", "value":"0", "type":"input"}, {"field":"seo_title", "value":"", "type":"input"}, {"field":"seo_keywords", "value":"", "type":"input"}, {"field":"seo_desc", "value":"", "type":"textarea"}]'>
<div class="m-t-30 t-c">
<img src="{{$attachment_host}}/static/common/images/loading.gif" />
<p>处理中...</p>
......
<div class="am-form-group">
<label>SEO标题<span class="am-form-group-label-tips">一般不超过80个字符</span></label>
<input type="text" name="seo_title" placeholder="SEO标题" maxlength="100" data-validation-message="SEO标题格式 最多80个字符" class="am-radius" {{if !empty($data['seo_title'])}} value="{{$data.seo_title}}"{{/if}} />
</div>
<div class="am-form-group">
<label>SEO关键字<span class="am-form-group-label-tips">一般不超过100个字符,多个关键字以半圆角逗号 [ , ] 隔开</span></label>
<input type="text" name="seo_keywords" placeholder="SEO关键字" maxlength="130" data-validation-message="SEO关键字格式 最多130个字符" class="am-radius" {{if !empty($data['seo_keywords'])}} value="{{$data.seo_keywords}}"{{/if}} />
</div>
<div class="am-form-group">
<label>SEO描述<span class="am-form-group-label-tips">一般不超过200个字符</span></label>
<textarea rows="4" name="seo_desc" maxlength="230" class="am-radius" placeholder="SEO描述" data-validation-message="SEO描述格式 最多230个字符">{{if !empty($data['seo_desc'])}}{{$data.seo_desc}}{{/if}}</textarea>
</div>
\ No newline at end of file
......@@ -38,8 +38,8 @@
<!-- plugins config start -->
{{if !empty($data['element'])}}
<div class="plugins-element">
<p class="tips">该区域为插件配置填写项,请按照插件文档填写相应的值。</p>
<div class="am-alert am-alert-secondary">
<label class="am-text-sm am-text-warning">该区域为插件配置填写项,请按照插件文档填写相应的值。</label>
{{foreach $data.element as $element}}
<div class="am-form-group">
<label class="block">{{$element.title}}</label>
......
......@@ -48,7 +48,7 @@ class Article extends Common
$id = input('id');
$params = [
'where' => ['a.is_enable'=>1, 'a.id'=>$id],
'field' => 'a.id,a.title,a.title_color,a.jump_url,a.content,a.access_count,a.article_category_id,a.add_time',
'field' => 'a.id,a.title,a.title_color,a.jump_url,a.content,a.access_count,a.article_category_id,seo_title,seo_keywords,seo_desc,a.add_time',
'm' => 0,
'n' => 1,
];
......@@ -64,13 +64,22 @@ class Article extends Common
return redirect($article['data'][0]['jump_url']);
}
// 浏览器标题
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($article['data'][0]['title']));
// 获取分类和文字
$article_category_content = ArticleService::ArticleCategoryListContent();
$this->assign('category_list', $article_category_content['data']);
// seo
$seo_title = empty($article['data'][0]['seo_title']) ? $article['data'][0]['title'] : $article['data'][0]['seo_title'];
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($seo_title, 2));
if(!empty($article['data'][0]['seo_keywords']))
{
$this->assign('home_seo_site_keywords', $article['data'][0]['seo_keywords']);
}
if(!empty($article['data'][0]['seo_desc']))
{
$this->assign('home_seo_site_description', $article['data'][0]['seo_desc']);
}
$this->assign('article', $article['data'][0]);
return $this->fetch();
} else {
......
......@@ -78,14 +78,15 @@ class Goods extends Common
$this->assign('goods', $ret['data'][0]);
// seo
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($ret['data'][0]['title'], 2));
$seo_title = empty($ret['data'][0]['seo_title']) ? $ret['data'][0]['title'] : $ret['data'][0]['seo_title'];
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($seo_title, 2));
if(!empty($ret['data'][0]['seo_keywords']))
{
$this->assign('home_seo_site_keywords', SeoService::BrowserSeoTitle($ret['data'][0]['seo_keywords'], 2));
$this->assign('home_seo_site_keywords', $ret['data'][0]['seo_keywords']);
}
if(!empty($ret['data'][0]['seo_desc']))
{
$this->assign('home_seo_site_description', SeoService::BrowserSeoTitle($ret['data'][0]['seo_desc'], 2));
$this->assign('home_seo_site_description', $ret['data'][0]['seo_desc']);
}
// 二维码
......
......@@ -68,19 +68,44 @@ class Search extends Common
// 参数
$this->assign('params', $this->params);
// 浏览器名称
if(!empty($this->params['category_id']))
{
$seo_name = GoodsService::GoodsCategoryValue($this->params['category_id'], 'name', '商品搜索');
} else {
$seo_name = empty($this->params['wd']) ? '商品搜索' : $this->params['wd'];
}
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($seo_name, 1));
// seo
$this->SetSeo();
return $this->fetch();
}
}
/**
* seo设置
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-06-02T21:29:04+0800
*/
private function SetSeo()
{
$seo_title = $this->params['wd'];
if(!empty($this->params['category_id']))
{
$category = GoodsService::GoodsCategoryRow(['id'=>$this->params['category_id'], 'field'=>'name,seo_title,seo_keywords,seo_desc']);
if(!empty($category))
{
$seo_title = empty($category['seo_title']) ? $category['name'] : $category['seo_title'];
// 关键字和描述
if(!empty($category['seo_keywords']))
{
$this->assign('home_seo_site_keywords', $category['seo_keywords']);
}
if(!empty($category['seo_desc']))
{
$this->assign('home_seo_site_description', $category['seo_desc']);
}
}
}
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle(empty($seo_title) ? '商品搜索' : $seo_title, 1));
}
/**
* 参数初始化
* @author Devil
......
......@@ -181,6 +181,27 @@ class ArticleService
'checked_data' => '10,105000',
'error_msg' => '内容 10~105000 个字符',
],
[
'checked_type' => 'length',
'key_name' => 'seo_title',
'checked_data' => '100',
'is_checked' => 1,
'error_msg' => 'SEO标题格式 最多100个字符',
],
[
'checked_type' => 'length',
'key_name' => 'seo_keywords',
'checked_data' => '130',
'is_checked' => 1,
'error_msg' => 'SEO关键字格式 最多130个字符',
],
[
'checked_type' => 'length',
'key_name' => 'seo_desc',
'checked_data' => '230',
'is_checked' => 1,
'error_msg' => 'SEO描述格式 最多230个字符',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
......@@ -203,6 +224,9 @@ class ArticleService
'image_count' => count($image),
'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0,
'is_home_recommended' => isset($params['is_home_recommended']) ? intval($params['is_home_recommended']) : 0,
'seo_title' => empty($params['seo_title']) ? '' : $params['seo_title'],
'seo_keywords' => empty($params['seo_keywords']) ? '' : $params['seo_keywords'],
'seo_desc' => empty($params['seo_desc']) ? '' : $params['seo_desc'],
];
if(empty($params['id']))
......
......@@ -130,7 +130,7 @@ class GoodsService
public static function GoodsCategoryList($where = [])
{
$where['is_enable'] = 1;
$field = 'id,pid,icon,name,vice_name,describe,bg_color,big_images,sort,is_home_recommended';
$field = 'id,pid,icon,name,vice_name,describe,bg_color,big_images,sort,is_home_recommended,seo_title,seo_keywords,seo_desc';
$data = Db::name('GoodsCategory')->field($field)->where($where)->order('sort asc')->select();
return self::GoodsCategoryDataDealWith($data);
}
......@@ -998,6 +998,13 @@ class GoodsService
'key_name' => 'buy_min_number',
'error_msg' => '请填写有效的最低起购数量',
],
[
'checked_type' => 'length',
'key_name' => 'seo_title',
'checked_data' => '100',
'is_checked' => 1,
'error_msg' => 'SEO标题格式 最多100个字符',
],
[
'checked_type' => 'length',
'key_name' => 'seo_keywords',
......@@ -1070,6 +1077,7 @@ class GoodsService
'home_recommended_images' => $attachment['data']['home_recommended_images'],
'brand_id' => isset($params['brand_id']) ? intval($params['brand_id']) : 0,
'video' => $attachment['data']['video'],
'seo_title' => empty($params['seo_title']) ? '' : $params['seo_title'],
'seo_keywords' => empty($params['seo_keywords']) ? '' : $params['seo_keywords'],
'seo_desc' => empty($params['seo_desc']) ? '' : $params['seo_desc'],
];
......@@ -2002,7 +2010,7 @@ class GoodsService
$id = isset($params['id']) ? intval($params['id']) : 0;
// 获取数据
$field = 'id,pid,icon,name,sort,is_enable,bg_color,big_images,vice_name,describe,is_home_recommended';
$field = 'id,pid,icon,name,sort,is_enable,bg_color,big_images,vice_name,describe,is_home_recommended,seo_title,seo_keywords,seo_desc';
$data = Db::name('GoodsCategory')->field($field)->where(['pid'=>$id])->order('sort asc')->select();
if(!empty($data))
{
......@@ -2052,6 +2060,27 @@ class GoodsService
'is_checked' => 1,
'error_msg' => '描述格式 最多200个字符',
],
[
'checked_type' => 'length',
'key_name' => 'seo_title',
'checked_data' => '100',
'is_checked' => 1,
'error_msg' => 'SEO标题格式 最多100个字符',
],
[
'checked_type' => 'length',
'key_name' => 'seo_keywords',
'checked_data' => '130',
'is_checked' => 1,
'error_msg' => 'SEO关键字格式 最多130个字符',
],
[
'checked_type' => 'length',
'key_name' => 'seo_desc',
'checked_data' => '230',
'is_checked' => 1,
'error_msg' => 'SEO描述格式 最多230个字符',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
......@@ -2079,6 +2108,9 @@ class GoodsService
'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0,
'icon' => $attachment['data']['icon'],
'big_images' => $attachment['data']['big_images'],
'seo_title' => empty($params['seo_title']) ? '' : $params['seo_title'],
'seo_keywords' => empty($params['seo_keywords']) ? '' : $params['seo_keywords'],
'seo_desc' => empty($params['seo_desc']) ? '' : $params['seo_desc'],
];
// 父级id宇当前id不能相同
......@@ -2163,21 +2195,5 @@ class GoodsService
}
return DataReturn('删除失败', -100);
}
/**
* 获取商品分类字段字段数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-06-02T01:51:31+0800
* @param [int] $category_id [商品分类id]
* @param [string] $field [指定字段值]
* @param [string] $default [默认值]
*/
public static function GoodsCategoryValue($category_id, $field, $default = null)
{
$value = Db::name('GoodsCategory')->where(['id'=>intval($category_id)])->value($field);
return ($value === null) ? $default : $value;
}
}
?>
\ No newline at end of file
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -564,4 +564,11 @@ table.am-table .am-btn-danger:hover {
}
#tree table.am-table td button.am-btn {
vertical-align: unset;
}
/**
* 警告框下表单最后一个去掉虚线
*/
.am-alert .am-form-group:last-child {
border-bottom: 0;
}
\ No newline at end of file
......@@ -4,10 +4,4 @@
table.am-table .th-desc { width: 20%; }
table.am-table .td-desc, table.am-table .td-version { font-size: 12px; }
table.am-table .td-version { color: #d2364c; margin: 0; }
.am-form-file input[type="file"] { margin-top: 0; }
/**
* 插件部分
*/
.plugins-element { border: 1px dotted #FFC107; background: #fffcf2; padding: 10px 10px 0 10px; margin-bottom: 10px; border-radius: 2px; }
.plugins-element .tips { color: #FF9800; margin: 0 0 10px 0; font-size: 12px; }
\ No newline at end of file
.am-form-file input[type="file"] { margin-top: 0; }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册