Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
b584613e
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
17
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b584613e
编写于
9月 06, 2016
作者:
R
root
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
category left fileter sub category
上级
d030e8d4
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
344 addition
and
45 deletion
+344
-45
app/appfront/modules/Catalog/block/category/Index.php
app/appfront/modules/Catalog/block/category/Index.php
+44
-0
app/appfront/theme/base/front/assets/css/style.css
app/appfront/theme/base/front/assets/css/style.css
+16
-5
app/appfront/theme/base/front/assets/images/checkbox.png
app/appfront/theme/base/front/assets/images/checkbox.png
+0
-0
app/appfront/theme/base/front/catalog/category/index.php
app/appfront/theme/base/front/catalog/category/index.php
+26
-15
app/appfront/theme/base/front/catalog/category/index/filter/attr.php
...t/theme/base/front/catalog/category/index/filter/attr.php
+10
-4
app/appfront/theme/base/front/catalog/category/index/filter/price.php
.../theme/base/front/catalog/category/index/filter/price.php
+11
-4
app/appfront/theme/base/front/catalog/category/index/filter/subcategory.php
.../base/front/catalog/category/index/filter/subcategory.php
+19
-0
app/appfront/theme/base/front/cms/article/index.php
app/appfront/theme/base/front/cms/article/index.php
+7
-4
app/appfront/theme/base/front/site/helper/error.php
app/appfront/theme/base/front/site/helper/error.php
+15
-12
services/Category.php
services/Category.php
+3
-1
services/category/CategoryMongodb.php
services/category/CategoryMongodb.php
+193
-0
未找到文件。
app/appfront/modules/Catalog/block/category/Index.php
浏览文件 @
b584613e
...
...
@@ -53,10 +53,54 @@ class Index {
'query_item'
=>
$this
->
getQueryItem
(),
'product_page'
=>
$this
->
getProductPage
(),
'filter_price'
=>
$this
->
getFilterPrice
(),
'filter_category'
=>
$this
->
getFilterCategoryHtml
(),
//'content' => Yii::$service->store->getStoreAttrVal($this->_category['content'],'content'),
//'created_at' => $this->_category['created_at'],
];
}
/**
* 得到子分类,如果子分类不存在,则返回同级分类。
*/
protected
function
getFilterCategory
(){
$category_id
=
$this
->
_primaryVal
;
$parent_id
=
$this
->
_category
[
'parent_id'
];
$filter_category
=
Yii
::
$service
->
category
->
getFilterCategory
(
$category_id
,
$parent_id
);
return
$filter_category
;
}
protected
function
getFilterCategoryHtml
(
$filter_category
=
''
){
$str
=
''
;
if
(
!
$filter_category
){
$filter_category
=
$this
->
getFilterCategory
();
}
//var_dump($filter_category);
//exit;
if
(
is_array
(
$filter_category
)
&&
!
empty
(
$filter_category
)){
$str
.
=
'<ul>'
;
foreach
(
$filter_category
as
$cate
){
//var_dump($cate);
//echo '<br><br>';
//continue;
$name
=
Yii
::
$service
->
store
->
getStoreAttrVal
(
$cate
[
'name'
],
'name'
);
$url
=
Yii
::
$service
->
url
->
getUrl
(
$cate
[
'url_key'
]);
$current
=
''
;
if
(
isset
(
$cate
[
'current'
])
&&
$cate
[
'current'
]){
$current
=
'class="current"'
;
}
$str
.
=
'<li '
.
$current
.
'><a href="'
.
$url
.
'">'
.
$name
.
'</a>'
;
if
(
isset
(
$cate
[
'child'
])
&&
is_array
(
$cate
[
'child'
]
)
&&
!
empty
(
$cate
[
'child'
])){
$str
.
=
$this
->
getFilterCategoryHtml
(
$cate
[
'child'
]);
}
$str
.
=
'</li>'
;
}
$str
.
=
'</ul>'
;
}
//exit;
return
$str
;
}
protected
function
getProductPage
(){
$spaceShowNum
=
4
;
...
...
app/appfront/theme/base/front/assets/css/style.css
浏览文件 @
b584613e
...
...
@@ -3,7 +3,7 @@ body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset,
body
{
color
:
#333
;
font
:
1em
/
1.55
Verdana
,
Arial
,
Helvetica
,
sans-serif
;}
a
{
color
:
#666
;
text-decoration
:
none
;}
ol
,
ul
{
list-style
:
outside
none
none
;}
ul
li
{
height
:
32px
;}
#top_nav
{
background-color
:
#000
;
font-size
:
0.75em
;
height
:
40px
;
line-height
:
40px
;
width
:
100%
;}
.top_nav_inner
{
height
:
100%
;
width
:
1200px
;}
...
...
@@ -185,7 +185,7 @@ a:active, a:link {
position
:
relative
;
}
.main.container
{
width
:
1200px
;
margin
:
auto
;
min-height
:
5
00px
;}
.main.container
{
width
:
1200px
;
margin
:
auto
;
min-height
:
4
00px
;}
.t_hidden
{
font
:
0px
/
0
Verdana
;
...
...
@@ -194,7 +194,7 @@ a:active, a:link {
.topSeachForm
.seachBtn
{
cursor
:
pointer
;
}
.col-main
.site-error
h1
{
font-size
:
22px
;
margin-bottom
:
20px
;}
#nav
{
margin
:
0
auto
;
...
...
@@ -650,8 +650,19 @@ input.input-text {
.breadcrumbs
span
{
font-size
:
0.85em
;}
.breadcrumbs
{
margin
:
0
0
10px
0
}
.filter_attr_info
a
{
background
:
rgba
(
0
,
0
,
0
,
0
)
url("../images/checkbox.png")
no-repeat
scroll
-69px
3px
;
padding
:
0
0
0
16px
;
font-size
:
0.8em
;
}
.filter_attr_info
a
.checked
{
background-position
:
-50px
-17px
;
}
.filter_attr_title
{
font-size
:
0.9em
;
text-transform
:
uppercase
;
}
.filter_attr
{
margin
:
0
0
20px
0
}
...
...
app/appfront/theme/base/front/assets/images/checkbox.png
0 → 100644
浏览文件 @
b584613e
1.5 KB
app/appfront/theme/base/front/catalog/category/index.php
浏览文件 @
b584613e
...
...
@@ -21,20 +21,22 @@
<?=
$description
?>
</div>
<div
class=
"panelBar"
>
<?php
$parentThis
=
[
'query_item'
=>
$query_item
,
'product_page'
=>
$product_page
,
];
$config
=
[
'view'
=>
'catalog/category/index/toolbar.php'
,
];
$toolbar
=
Yii
::
$service
->
page
->
widget
->
renderContent
(
'category_toolbar'
,
$config
,
$parentThis
);
echo
$toolbar
;
?>
<?php
if
(
is_array
(
$products
)
&&
!
empty
(
$products
)){
?>
<?php
$parentThis
=
[
'query_item'
=>
$query_item
,
'product_page'
=>
$product_page
,
];
$config
=
[
'view'
=>
'catalog/category/index/toolbar.php'
,
];
$toolbar
=
Yii
::
$service
->
page
->
widget
->
renderContent
(
'category_toolbar'
,
$config
,
$parentThis
);
echo
$toolbar
;
?>
<?php
}
?>
</div>
<div
class=
"category_product"
>
<?php
if
(
is_array
(
$products
)){
?>
<?php
if
(
is_array
(
$products
)
&&
!
empty
(
$products
)
){
?>
<?php
$i
=
0
;
foreach
(
$products
as
$product
){
?>
<?php
if
(
$i
%
$count
==
0
){
?>
<ul>
...
...
@@ -72,12 +74,22 @@
</div>
<div
class=
"clear"
></div>
<div
class=
"panelBar"
>
<?php
echo
$toolbar
;
?>
<?php
if
(
is_array
(
$products
)
&&
!
empty
(
$products
)){
?>
<?php
echo
$toolbar
;
?>
<?php
}
?>
</div>
</div>
</div>
<div
class=
"col-left "
>
<?php
$parentThis
=
[
'filter_category'
=>
$filter_category
,
];
$config
=
[
'view'
=>
'catalog/category/index/filter/subcategory.php'
,
];
echo
Yii
::
$service
->
page
->
widget
->
renderContent
(
'category_product_filter_sub_category'
,
$config
,
$parentThis
);
?>
<?php
$parentThis
=
[
'filters'
=>
$filter_info
,
...
...
@@ -88,7 +100,6 @@
echo
Yii
::
$service
->
page
->
widget
->
renderContent
(
'category_product_filter_attr'
,
$config
,
$parentThis
);
?>
<?php
$parentThis
=
[
'filter_price'
=>
$filter_price
,
];
...
...
app/appfront/theme/base/front/catalog/category/index/filter/attr.php
浏览文件 @
b584613e
...
...
@@ -7,6 +7,7 @@
* @license http://www.fecshop.com/license/
*/
?>
<div
class=
"category_left_filter"
>
<?php
//var_dump($parentThis);
//echo 1;
...
...
@@ -15,16 +16,21 @@ if(isset($parentThis['filters']) && !empty($parentThis['filters']) && is_array($
foreach
(
$parentThis
[
'filters'
]
as
$attr
=>
$filter
){
$attrUrlStr
=
Yii
::
$service
->
url
->
category
->
attrValConvertUrlStr
(
$attr
);
if
(
is_array
(
$filter
)
&&
!
empty
(
$filter
)){
echo
$attr
.
'<br/>'
;
echo
'<div class="filter_attr">'
;
echo
'<div class="filter_attr_title">'
.
$attr
.
'</div>'
;
echo
'<div class="filter_attr_info">'
;
foreach
(
$filter
as
$item
){
$val
=
$item
[
'_id'
];
$count
=
$item
[
'count'
];
$urlInfo
=
Yii
::
$service
->
url
->
category
->
getFilterChooseAttrUrl
(
$attrUrlStr
,
$val
,
'p'
);
$url
=
$urlInfo
[
'url'
];
$selected
=
$urlInfo
[
'selected'
];
echo
'<a href="'
.
$url
.
'">'
.
$val
.
'('
.
$count
.
')</a><br/>'
;
$selected
=
$urlInfo
[
'selected'
]
?
'class="checked"'
:
''
;
echo
'<a
'
.
$selected
.
'
href="'
.
$url
.
'">'
.
$val
.
'('
.
$count
.
')</a><br/>'
;
}
echo
'</div>'
;
echo
'</div>'
;
}
}
}
?>
\ No newline at end of file
?>
</div>
\ No newline at end of file
app/appfront/theme/base/front/catalog/category/index/filter/price.php
浏览文件 @
b584613e
...
...
@@ -7,6 +7,7 @@
* @license http://www.fecshop.com/license/
*/
?>
<div
class=
"category_left_filter"
>
<?php
//var_dump($parentThis['filter_price']);
//echo 1;
...
...
@@ -14,17 +15,23 @@
if
(
isset
(
$parentThis
[
'filter_price'
])
&&
!
empty
(
$parentThis
[
'filter_price'
])
&&
is_array
(
$parentThis
[
'filter_price'
])){
foreach
(
$parentThis
[
'filter_price'
]
as
$attr
=>
$filter
){
//var_dump($filter);
echo
$attr
.
'<br/>'
;
$attrUrlStr
=
Yii
::
$service
->
url
->
category
->
attrValConvertUrlStr
(
$attr
);
if
(
is_array
(
$filter
)
&&
!
empty
(
$filter
)){
echo
'<div class="filter_attr">'
;
echo
'<div class="filter_attr_title">'
.
$attr
.
'</div>'
;
echo
'<div class="filter_attr_info">'
;
foreach
(
$filter
as
$item
){
$val
=
$item
[
'val'
];
$url
=
$item
[
'url'
];
$selected
=
$item
[
'selected'
]
?
'class="checked"'
:
''
;
echo
'<a '
.
$selected
.
' href="'
.
$url
.
'">'
.
$val
.
'</a><br/>'
;
if
(
$val
&&
$url
){
echo
'<a '
.
$selected
.
' href="'
.
$url
.
'">'
.
$val
.
'</a><br/>'
;
}
}
echo
'</div>'
;
echo
'</div>'
;
}
}
}
?>
\ No newline at end of file
?>
</div>
\ No newline at end of file
app/appfront/theme/base/front/catalog/category/index/filter/subcategory.php
浏览文件 @
b584613e
<style>
.category_left_filter_category
ul
li
{
}
.category_left_filter_category
ul
li
.current
>
a
{
color
:
#cc0000
;
}
.category_left_filter_category
ul
{
margin-left
:
20px
;
}
</style>
<div
class=
"category_left_filter_category"
>
<?php
echo
$parentThis
[
'filter_category'
];
?>
<?php
//exit;
?>
</div>
<div
class=
"clear"
></div>
\ No newline at end of file
app/appfront/theme/base/front/cms/article/index.php
浏览文件 @
b584613e
...
...
@@ -7,8 +7,11 @@
* @license http://www.fecshop.com/license/
*/
?>
<h1>
<?=
$title
?>
</h1>
<div>
<?=
$content
?>
<div
class=
"main container one-column"
>
<div
class=
"col-main"
>
<h1>
<?=
$title
?>
</h1>
<div>
<?=
$content
?>
</div>
</div>
</div>
\ No newline at end of file
app/appfront/theme/base/front/site/helper/error.php
浏览文件 @
b584613e
...
...
@@ -9,19 +9,22 @@ use yii\helpers\Html;
$this
->
title
=
$name
;
?>
<div
class=
"site-error"
>
<div
class=
"main container one-column"
>
<div
class=
"col-main"
>
<div
class=
"site-error"
>
<h1>
<?=
Html
::
encode
(
$this
->
title
)
?>
</h1>
<h1>
<?=
Html
::
encode
(
$this
->
title
)
?>
</h1>
<div
class=
"alert alert-danger"
>
<?=
nl2br
(
Html
::
encode
(
$message
))
?>
</div>
<div
class=
"alert alert-danger"
>
<?=
nl2br
(
Html
::
encode
(
$message
))
?>
</div>
<p>
The above error occurred while the Web server was processing your request.
</p>
<p>
Please contact us if you think this is a server error. Thank you.
</p>
<p>
The above error occurred while the Web server was processing your request.
</p>
<p>
Please contact us if you think this is a server error. Thank you.
</p>
</div>
</div>
</div>
\ No newline at end of file
services/Category.php
浏览文件 @
b584613e
...
...
@@ -98,7 +98,9 @@ class Category extends Service
}
protected
function
actionGetFilterCategory
(
$category_id
,
$parent_id
){
return
$this
->
_category
->
getFilterCategory
(
$category_id
,
$parent_id
);
}
...
...
services/category/CategoryMongodb.php
浏览文件 @
b584613e
...
...
@@ -195,6 +195,199 @@ class CategoryMongodb implements CategoryInterface
return
$parent_category
;
}
}
/**
* 得到分类的侧栏过滤信息
*/
/*
[
['name' => 'xxx','url_key'=>'xxx'],
[
'name' => 'xxx',
'url_key'=>'xxx',
'child' => [
['name' => 'xxx','url_key'=>'xxx'],
['name' => 'xxx','url_key'=>'xxx'],
[
'name' => 'xxx',
'url_key'=>'xxx',
'current' => true,
'child' => [
['name' => 'xxx','url_key'=>'xxx'],
['name' => 'xxx','url_key'=>'xxx'],
['name' => 'xxx','url_key'=>'xxx'],
]
],
]
],
['name' => 'xxx','url_key'=>'xxx'],
['name' => 'xxx','url_key'=>'xxx'],
]
*/
public
function
getParentCategory
(
$parent_id
){
if
(
$parent_id
===
'0'
){
return
[];
}
$category
=
Category
::
find
()
->
asArray
()
->
where
([
'_id'
=>
new
\
mongoId
(
$parent_id
)])
->
one
();
if
(
isset
(
$category
[
'_id'
])
&&
!
empty
(
$category
[
'_id'
])
){
$currentUrlKey
=
$category
[
'url_key'
];
$currentName
=
$category
[
'name'
];
$currentId
=
$category
[
'_id'
]
->
{
'$id'
};
$currentCategory
[]
=
[
'_id'
=>
$currentId
,
'name'
=>
$currentName
,
'url_key'
=>
$currentUrlKey
,
'parent_id'
=>
$category
[
'parent_id'
],
];
$parentCategory
=
$this
->
getParentCategory
(
$category
[
'parent_id'
]);
return
array_merge
(
$parentCategory
,
$currentCategory
);
}
else
{
return
[];
}
}
public
function
getFilterCategory
(
$category_id
,
$parent_id
){
# 1.如果level为一级,那么title部分为当前的分类,子分类位一级分类下的二级分类
# 2.如果level为二级,那么将所有的二级分类列出,当前的二级分类,列出来子分类
# 3.如果level为三级,那么将所有的二级分类列出。
# 当前二级分类的所有子分类列出,当前三级分类如果有子分类,则列出
//echo $category_id.'##';
//echo $parent_id;
$returnData
=
[];
$primaryKey
=
$this
->
getPrimaryKey
();
$currentCategory
=
Category
::
findOne
(
$category_id
);
$currentUrlKey
=
$currentCategory
[
'url_key'
];
$currentName
=
$currentCategory
[
'name'
];
$currentId
=
$currentCategory
[
'_id'
]
->
{
'$id'
};
//var_dump($currentCategory);exit;
$returnData
[
'current'
]
=
[
'_id'
=>
$currentId
,
'name'
=>
$currentName
,
'url_key'
=>
$currentUrlKey
,
'parent_id'
=>
$currentCategory
[
'parent_id'
],
];
//echo $currentCategory['parent_id'];
//exit;
if
(
$currentCategory
[
'parent_id'
]){
$allParent
=
$this
->
getParentCategory
(
$currentCategory
[
'parent_id'
]);
$allParent
[]
=
$returnData
[
'current'
];
$data
=
$this
->
getAllParentCate
(
$allParent
);
}
else
{
// 点击的是一级分类的时候
$data
=
$this
->
getOneLevelCateChild
(
$returnData
[
'current'
]);
}
//$data = $this->getChildCate($currentId);
//var_dump($data);exit;
return
$data
;
}
public
function
getOneLevelCateChild
(
$category
){
//'_id' => $currentId,
//'name' => $currentName,
//'url_key' => $currentUrlKey,
$data
[
0
]
=
$category
;
$_id
=
$category
[
'_id'
];
$name
=
$category
[
'name'
];
$url_key
=
$category
[
'url_key'
];
$cate
=
Category
::
find
()
->
asArray
()
->
where
([
'parent_id'
=>
$_id
,
])
->
all
();
if
(
is_array
(
$cate
)
&&
!
empty
(
$cate
)){
foreach
(
$cate
as
$one
){
$c_id
=
$one
[
'_id'
]
->
{
'$id'
};
$data
[
0
][
'child'
][
$c_id
]
=
[
'name'
=>
$one
[
'name'
],
'url_key'
=>
$one
[
'url_key'
],
'parent_id'
=>
$one
[
'parent_id'
],
];
}
}
return
$data
;
}
public
function
getAllParentCate
(
$allParent
){
//var_dump($allParent);exit;
$d
=
$allParent
;
$data
=
[];
if
(
is_array
(
$allParent
)
&&
!
empty
(
$allParent
)){
foreach
(
$allParent
as
$k
=>
$category
){
unset
(
$d
[
$k
]);
$category_id
=
$category
[
'_id'
];
$parent_id
=
$category
[
'parent_id'
];
if
(
$parent_id
){
$cate
=
Category
::
find
()
->
asArray
()
->
where
([
'parent_id'
=>
$parent_id
,
])
->
all
();
//var_dump($cate);
//echo '$$$$$$$$$$';
if
(
is_array
(
$cate
)
&&
!
empty
(
$cate
)){
//echo '**********';
foreach
(
$cate
as
$one
){
$c_id
=
$one
[
'_id'
]
->
{
'$id'
};
$data
[
$c_id
]
=
[
'name'
=>
$one
[
'name'
],
'url_key'
=>
$one
[
'url_key'
],
'parent_id'
=>
$one
[
'parent_id'
],
];
//echo $category_id;
//echo '&&&'.$c_id;
if
((
$c_id
==
$category_id
)
&&
!
empty
(
$d
)){
$data
[
$c_id
][
'child'
]
=
$this
->
getAllParentCate
(
$d
);
}
if
((
$c_id
==
$category_id
)
&&
empty
(
$d
)){
$child_cate
=
$this
->
getChildCate
(
$c_id
);
$data
[
$c_id
][
'current'
]
=
true
;
if
(
!
empty
(
$child_cate
)){
$data
[
$c_id
][
'child'
]
=
$child_cate
;
}
}
}
}
break
;
}
}
}
return
$data
;
}
public
function
getChildCate
(
$category_id
){
//echo $category_id;
$data
=
Category
::
find
()
->
asArray
()
->
where
([
'parent_id'
=>
$category_id
,
])
->
all
();
$arr
=
[];
if
(
is_array
(
$data
)
&&
!
empty
(
$data
)){
foreach
(
$data
as
$one
){
$currentUrlKey
=
$one
[
'url_key'
];
$currentName
=
$one
[
'name'
];
$currentId
=
$one
[
'_id'
]
->
{
'$id'
};
$arr
[
$currentId
]
=
[
//'_id' => $currentId,
'name'
=>
$currentName
,
'url_key'
=>
$currentUrlKey
,
'parent_id'
=>
$one
[
'parent_id'
],
];
}
}
return
$arr
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录