Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Fixed categories components template

givanzc42fe60164bb
diff --git a/app/template/components/categories.tpl b/app/template/components/categories.tpl
index 498a0ca..3470bf3 100755
--- a/app/template/components/categories.tpl
+++ b/app/template/components/categories.tpl
@@ -1,21 +1,39 @@
@categories = [data-v-component-categories] [data-v-cats]
-@category = [data-v-component-categories] [data-v-cats] [data-v-cat]
+@category = [data-v-component-categories] [data-v-cats] [data-v-cat]
@categories|deleteAllButFirstChild
@category|deleteAllButFirstChild
-@categories|before = <?php
-if (isset($_categories_idx)) $_categories_idx++; else $_categories_idx = 0;
+[data-v-component-categories]|prepend = <?php
+//make sure that the instance is unique even if the component is added into a loop inside a compomonent like data-v-posts
+$line = __LINE__;
+if (isset($_categories_idx)){
+ if (!isset($_product_categories[$line])) {
+ $_categories_idx++;
+ $_product_categories[$line] = $_categories_idx;
+ }
+} else {
+ $_categories_idx = 0;
+ $_product_categories[$line] = $_categories_idx;
+}
$_categories = [];
+if (isset($this->_component['categories'][$_categories_idx])) {
+ $_pagination_count = $count = $this->_component['categories'][$_categories_idx]['count'] ?? 0;
+ //$_pagination_limit = $this->product_categories[$_categories_idx]['limit'];
+ $_categories = $this->_component['categories'][$_categories_idx]['categories'] ?? [];
+}
+
$previous_component = isset($current_component)?$current_component:null;
$categories = $current_component = $this->_component['categories'][$_categories_idx] ?? [];
$_categories = $categories['categories'] ?? [];
$_pagination_count = $categories['count'] ?? 0;
$_pagination_limit = isset($categories['limit']) ? $categories['limit'] : 5;
+?>
+@categories|before = <?php
if ($_categories) {
$generate_menu = function ($parent) use (&$_categories, &$generate_menu) {
@@ -23,13 +41,20 @@ $generate_menu = function ($parent) use (&$_categories, &$generate_menu) {
@category|before = <?php
foreach($_categories as $id => $category) {
- if ($category['parent_id'] == $parent) { ?>
+ if ($category['parent_id'] == $parent) {
+ ?>
//catch all data attributes
@category [data-v-cat-*]|innerText = $category['@@__data-v-cat-(*)__@@']
- @category [data-v-cat-url]|href = <?php echo htmlspecialchars(Vvveb\url('content/category/index', $category));?>
- @category [data-v-cat-img]|src = $category['images'][0]
+ @category [data-v-cat-url]|href = $category['url']
+ @category [data-v-cat-img]|src = $category['images'][0]
+
+ @category input|id = <?php echo 'm' . $category['taxonomy_item_id'];?>
+ @category input|addNewAttribute = <?php if (isset($category['active']) && $category['active']) echo 'checked';?>
+ @category label|for = <?php echo 'm' . $category['taxonomy_item_id'];?>
+
+ @category|addClass = <?php if (isset($category['active']) && $category['active']) echo 'active';?>
@category|append = <?php
$generate_menu($category['taxonomy_item_id'], $_categories);
@@ -39,6 +64,9 @@ $generate_menu = function ($parent) use (&$_categories, &$generate_menu) {
@categories|after = <?php
};
+
+if ($_categories) {
reset($_categories);
$generate_menu($_categories[key($_categories)]['parent_id'], $_categories); }
-?>
\ No newline at end of file
+}
+?>
diff --git a/app/template/components/content/categories.tpl b/app/template/components/content/categories.tpl
index 3665c71..59ccc30 100755
--- a/app/template/components/content/categories.tpl
+++ b/app/template/components/content/categories.tpl
@@ -1,8 +1,10 @@
-@cats = [data-v-component-content-categories] [data-v-cats]
-@cats|deleteAllButFirstChild
-@cats [data-v-cat]|deleteAllButFirstChild
+@categories = [data-v-component-content-categories] [data-v-cats]
+@category = [data-v-component-content-categories] [data-v-cats] [data-v-cat]
-@cats|prepend = <?php
+@categories|deleteAllButFirstChild
+@category|deleteAllButFirstChild
+
+[data-v-component-content-categories]|prepend = <?php
//make sure that the instance is unique even if the component is added into a loop inside a compomonent like data-v-posts
$line = __LINE__;
if (isset($_content_categories_idx)){
@@ -14,48 +16,57 @@ if (isset($_content_categories_idx)){
$_content_categories_idx = 0;
$_content_categories[$line] = $_content_categories_idx;
}
+
$_categories = [];
-if (isset($this->content_categories[$_content_categories_idx])) {
- $_pagination_count = $count = $this->content_categories[$_content_categories_idx]['count'] ?? 0;
- //$_pagination_limit = $this->content_categories[$_categories_idx]['limit'];
- $_categories = $this->content_categories[$_content_categories_idx]['categories'] ?? [];
+if (isset($this->_component['content_categories'][$_content_categories_idx])) {
+ $_pagination_count = $count = $this->_component['content_categories'][$_content_categories_idx]['count'] ?? 0;
+ //$_pagination_limit = $this->content_categories[$_content_categories_idx]['limit'];
+ $_categories = $this->_component['content_categories'][$_content_categories_idx]['categories'] ?? [];
}
$previous_component = isset($current_component)?$current_component:null;
-$content_categories = $current_component = $this->_component['content_categories'][$_content_categories_idx] ?? [];
-
-$_pagination_count = $content_categories['count'] ?? 0;
-$_pagination_limit = isset($content_categories['limit']) ? $content_categories['limit'] : 5;
-$_categories = $content_categories['categories'] ?? [];
+$categories = $current_component = $this->_component['content_categories'][$_content_categories_idx] ?? [];
+$_categories = $categories['categories'] ?? [];
+$_pagination_count = $categories['count'] ?? 0;
+$_pagination_limit = isset($categories['limit']) ? $categories['limit'] : 5;
+?>
+
+@categories|before = <?php
if ($_categories) {
$generate_menu = function ($parent) use (&$_categories, &$generate_menu) {
?>
- @cats [data-v-cat]|before = <?php
+ @category|before = <?php
foreach($_categories as $id => $category) {
if ($category['parent_id'] == $parent) {
?>
//catch all data attributes
- @cats [data-v-cat] [data-v-cat-*]|innerText = $category['@@__data-v-cat-(*)__@@']
+ @category [data-v-cat-*]|innerText = $category['@@__data-v-cat-(*)__@@']
+
+ @category [data-v-cat-url]|href = $category['url']
+ @category [data-v-cat-img]|src = $category['images'][0]
- @cats [data-v-cat] [data-v-cat-url]|href = <?php echo htmlspecialchars(Vvveb\url('content/category/index', $category));?>
- @cats [data-v-cat] [data-v-cat-img]|src = $category['images'][0]
+ @category input|id = <?php echo 'm' . $category['taxonomy_item_id'];?>
+ @category input|addNewAttribute = <?php if (isset($category['active']) && $category['active']) echo 'checked';?>
+ @category label|for = <?php echo 'm' . $category['taxonomy_item_id'];?>
+
+ @category|addClass = <?php if (isset($category['active']) && $category['active']) echo 'active';?>
- @cats [data-v-cat]|after = <?php
+ @category|append = <?php
$generate_menu($category['taxonomy_item_id'], $_categories);
}
}
?>
- @cats|append = <?php
+ @categories|after = <?php
};
if ($_categories) {
- reset($_categories);
- $generate_menu($_categories[key($_categories)]['parent_id'], $_categories); }
+reset($_categories);
+$generate_menu($_categories[key($_categories)]['parent_id'] ?? 0, $_categories); }
}
?>
diff --git a/app/template/components/product/categories.tpl b/app/template/components/product/categories.tpl
index 484dbed..4eb863e 100755
--- a/app/template/components/product/categories.tpl
+++ b/app/template/components/product/categories.tpl
@@ -1,8 +1,10 @@
-@cats = [data-v-component-product-categories] [data-v-cats]
-@cats|deleteAllButFirstChild
-@cats [data-v-cat]|deleteAllButFirstChild
+@categories = [data-v-component-product-categories] [data-v-cats]
+@category = [data-v-component-product-categories] [data-v-cats] [data-v-cat]
-@cats|prepend = <?php
+@categories|deleteAllButFirstChild
+@category|deleteAllButFirstChild
+
+[data-v-component-product-categories]|prepend = <?php
//make sure that the instance is unique even if the component is added into a loop inside a compomonent like data-v-posts
$line = __LINE__;
if (isset($_product_categories_idx)){
@@ -17,42 +19,50 @@ if (isset($_product_categories_idx)){
$_categories = [];
-if (isset($this->product_categories[$_product_categories_idx])) {
- $_pagination_count = $count = $this->product_categories[$_product_categories_idx]['count'] ?? 0;
+if (isset($this->_component['product_categories'][$_product_categories_idx])) {
+ $_pagination_count = $count = $this->_component['product_categories'][$_product_categories_idx]['count'] ?? 0;
//$_pagination_limit = $this->product_categories[$_categories_idx]['limit'];
- $_categories = $this->product_categories[$_product_categories_idx]['categories'] ?? [];
+ $_categories = $this->_component['product_categories'][$_product_categories_idx]['categories'] ?? [];
}
$previous_component = isset($current_component)?$current_component:null;
$product_categories = $current_component = $this->_component['product_categories'][$_product_categories_idx] ?? [];
+$_categories = $product_categories['categories'] ?? [];
$_pagination_count = $product_categories['count'] ?? 0;
$_pagination_limit = isset($product_categories['limit']) ? $product_categories['limit'] : 5;
-$_categories = $product_categories['categories'] ?? [];
+?>
+@categories|before = <?php
if ($_categories) {
$generate_menu = function ($parent) use (&$_categories, &$generate_menu) {
?>
- @cats [data-v-cat]|before = <?php
+ @category|before = <?php
foreach($_categories as $id => $category) {
if ($category['parent_id'] == $parent) {
?>
//catch all data attributes
- @cats [data-v-cat] [data-v-cat-*]|innerText = $category['@@__data-v-cat-(*)__@@']
+ @category [data-v-cat-*]|innerText = $category['@@__data-v-cat-(*)__@@']
+
+ @category [data-v-cat-url]|href = $category['url']
+ @category [data-v-cat-img]|src = $category['images'][0]
- @cats [data-v-cat] [data-v-cat-url]|href = <?php echo htmlspecialchars(Vvveb\url('product/category/index', $category));?>
- @cats [data-v-cat] [data-v-cat-img]|src = $category['images'][0]
+ @category input|id = <?php echo 'm' . $category['taxonomy_item_id'];?>
+ @category input|addNewAttribute = <?php if (isset($category['active']) && $category['active']) echo 'checked';?>
+ @category label|for = <?php echo 'm' . $category['taxonomy_item_id'];?>
+
+ @category|addClass = <?php if (isset($category['active']) && $category['active']) echo 'active';?>
- @cats [data-v-cat]|after = <?php
+ @category|append = <?php
$generate_menu($category['taxonomy_item_id'], $_categories);
}
}
?>
- @cats|append = <?php
+ @categories|after = <?php
};
if ($_categories) {