diff --git a/app/controller/Article.php b/app/controller/Article.php index f8fbb77..e3f2aed 100644 --- a/app/controller/Article.php +++ b/app/controller/Article.php @@ -144,12 +144,13 @@ class Article extends Base { $cateIds[] = $article['category_id']; $currentCateId = input('param.source', 0); + $categoryList = Category::getChildrenByParentId($topCategory['id']); if($currentCateId == $topCategory['id']) { - $categoryList = Category::getChildrenByParentId($topCategory['id']); foreach ($categoryList as $cate) { $cateIds[] = $cate['id']; } } + $this->data['categoryChildren'] = $categoryList; $this->data['prev'] = MArticle::getPrevArticleByIdAndCategories($article['id'], $cateIds, true, $article['sort'], true); $this->data['next'] = MArticle::getNextArticleByIdAndCategories($article['id'], $cateIds, true, $article['sort'], true); $this->data['currentCateId'] = $currentCateId; diff --git a/app/controller/Index.php b/app/controller/Index.php index ff394ad..619bd35 100644 --- a/app/controller/Index.php +++ b/app/controller/Index.php @@ -16,19 +16,12 @@ class Index extends Base $this->data['blocks'] = $blocks; // 轮播图 $this->data['slides'] = Slide::getList(); - // 网络营销栏目ID + // 营销网络栏目ID $this->data['marketingCId'] = Category::$CIdList['marketing']; - // 关联产品中心 - $productsCId = Category::$CIdList['products']; - $productChildren = Category::getChildrenByParentId($productsCId); - $productsCIds[] = $productsCId; - foreach ($productChildren as $cate) { - $productsCIds[] = $cate['id']; - } - $this->data['products'] = [ - 'category' => Category::getById($productsCId), - 'items' => Article::getListByCategoryIds($productsCIds, 4, '', [], 1, ['create_time'=>'desc']) - ]; + // 关联产品分类 + $productsCenterCId = Category::$CIdList['products']; + $this->data['productsCenter'] = Category::getById($productsCenterCId); + $this->data['products'] = Category::getChildrenByParentId($productsCenterCId); // 关联新闻 $this->data['newsCenter'] = Category::getById(Category::$CIdList['news']); $newsCIdList = [Category::$CIdList['news_children']['enterprise'], Category::$CIdList['news_children']['industry']]; diff --git a/view/article/product.html b/view/article/product.html index 3992d66..df9388e 100644 --- a/view/article/product.html +++ b/view/article/product.html @@ -13,6 +13,23 @@
+
+ {if isset($categoryChildren) && count($categoryChildren) >0} + {foreach $categoryChildren as $idx => $cate} + {php} + $active = ''; + if($categoryId == $cate['id']) { + $active = 'active'; + } elseif ($categoryId == $topCategory['id'] && $idx == 0) { + $active = 'active'; + } + {/php} + + {/foreach} + {/if} +
{$article.title} diff --git a/view/article/products.html b/view/article/products.html index 4f8bf96..8b2c51d 100644 --- a/view/article/products.html +++ b/view/article/products.html @@ -28,6 +28,23 @@
--> +
+ {if isset($categoryChildren) && count($categoryChildren) >0} + {foreach $categoryChildren as $idx => $cate} + {php} + $active = ''; + if($categoryId == $cate['id']) { + $active = 'active'; + } elseif ($categoryId == $topCategory['id'] && $idx == 0) { + $active = 'active'; + } + {/php} + + {/foreach} + {/if} +
{if isset($items)}
diff --git a/view/index/index.html b/view/index/index.html index 70f667d..d0eef31 100644 --- a/view/index/index.html +++ b/view/index/index.html @@ -30,22 +30,23 @@
+
-
{$products['category']['title'] ?? '产品中心'} -

{$products['category']['description'] ?? 'product center'}

+
{$productsCenter['title'] ?? '产品中心'} +

{$productsCenter['description'] ?? 'product center'}

- {if isset($products) && count($products['items']) > 0} + {if isset($products) && count($products) > 0}
    - {foreach $products['items'] as $idx => $product} + {foreach $products as $idx => $product}
  • {$product['title']} -

    {$product['summary']|raw}

    +

    {$product['description']}

    - 了解详情+ + 了解详情+ {:str_pad($idx + 1, 2, '0', STR_PAD_LEFT)}
    @@ -56,6 +57,7 @@
+
@@ -71,6 +73,7 @@
+
{$newsCenter['title'] ?? '新闻动态'}{$newsCenter['description'] ?? ''}