Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
Taxonomy tag type support
givanz062e3ea44318
diff --git a/app/component/categories.php b/app/component/categories.phpindex 04fb1b4..6bb96ed 100755--- a/app/component/categories.php+++ b/app/component/categories.php@@ -22,6 +22,7 @@namespace Vvveb\Component;+use Vvveb\Sql\CategorySQL;use Vvveb\System\Component\ComponentBase;use Vvveb\System\Event;use Vvveb\System\Images;@@ -32,6 +33,7 @@ class Categories extends ComponentBase {'start' => 0,'limit' => 7,'site_id' => NULL,+ 'language_id' => NULL,'order' => ['url', 'price asc'],'taxonomy_id' => NULL,'post_id' => NULL,@@ -39,29 +41,50 @@ class Categories extends ComponentBase {'search' => NULL,'type' => 'categories','post_type' => NULL,+ 'count' => false, //include number of posts'parents_only' => false,'parents_children_only' => false,'parents_without_children' => false,];+ function cacheKey() {+ if (isset($this->options['search'])) {+ return false;+ }++ return parent::cacheKey();+ }+function results() {- $category = new \Vvveb\Sql\CategorySQL();+ $category = new CategorySQL();+$results = $category->getCategories($this->options);+ $taxonomy_type = 'category';++ if (isset($this->options['type']) && $this->options['type'] == 'tags') {+ $taxonomy_type = 'tag';+ }//count the number of child categories (subcategories) for each categoryif (isset($results['categories'])) {foreach ($results['categories'] as $taxonomy_item_id => &$category) {- $parent_id = $category['parent_id'] ?? false;+ $parent_id = $category['parent_id'] ?? false;+ $category['active'] = false;if (! isset($category['children'])) {$category['children'] = 0;}- if (isset($category['post_type'])) {- $category['type'] = $category['post_type'];+ if (isset($this->options['post_type']) && $this->options['post_type']) {+ $category['post_type'] = $this->options['post_type'];}- $category['url'] = url('content/category/index', $category);+ $url = ['slug' => $category['slug']];+ if ($category['post_type'] != 'post') {+ $url['type'] = $category['post_type'];+ }++ $category['url'] = url('content/' . $taxonomy_type . '/index', $url);if (isset($category['image'])) {$category['image_url'] = Images::image($category['image'], 'taxonomy_item');@@ -79,6 +102,10 @@ class Categories extends ComponentBase {}}+ $results['limit'] = $this->options['limit'];+ $results['start'] = $this->options['start'];+ $results['search'] = $this->options['search'] ?? '';+list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);return $results;@@ -93,7 +120,7 @@ class Categories extends ComponentBase {case 'product/category':$categoryId = $this->request->get['category_id'] ?? '';- break;+ break;}if (isset($results['categories']) && $categoryId) {diff --git a/app/component/content/categories.php b/app/component/content/categories.phpindex cea2551..492696d 100755--- a/app/component/content/categories.php+++ b/app/component/content/categories.php@@ -33,14 +33,15 @@ class Categories extends ComponentBase {'start' => 0,'limit' => 7,'site_id' => NULL,+ 'language_id' => NULL,'order' => ['url', 'price asc'],'taxonomy_id' => NULL,'post_id' => NULL,'parent_id' => NULL,'search' => NULL,- 'type' => 'categories',+ 'type' => 'categories', //tags'post_type' => 'post',- 'count' => false, //include number of posts+ 'count' => false, //include number of posts'parents_only' => false,'parents_children_only' => false,'parents_without_children' => false,@@ -49,24 +50,34 @@ class Categories extends ComponentBase {function results() {$category = new CategorySQL();+ $this->options['post_categories'] = true;$results = $category->getCategories($this->options);+ $taxonomy_type = 'category';++ if (isset($this->options['type']) && $this->options['type'] == 'tags') {+ $taxonomy_type = 'tag';+ }//count the number of child categories (subcategories) for each categoryif (isset($results['categories'])) {foreach ($results['categories'] as $taxonomy_item_id => &$category) {- $parent_id = $category['parent_id'] ?? false;+ $parent_id = $category['parent_id'] ?? false;+ $category['active'] = false;if (! isset($category['children'])) {$category['children'] = 0;}- if (isset($category['post_type'])) {- $category['type'] = $category['post_type'];+ if (isset($this->options['post_type']) && $this->options['post_type']) {+ $category['post_type'] = $this->options['post_type'];}- //$category['count'] = $category['count'] ?? 0;+ $url = ['slug' => $category['slug']];+ if ($category['post_type'] != 'post') {+ $url['type'] = $category['post_type'];+ }- $category['url'] = url('content/category/index', $category);+ $category['url'] = url('content/' . $taxonomy_type . '/index', $url);if (isset($category['image'])) {$category['image_url'] = Images::image($category['image'], 'taxonomy_item');@@ -98,7 +109,7 @@ class Categories extends ComponentBase {case 'product/category':$categoryId = $this->request->get['category_id'] ?? '';- break;+ break;}if (isset($results['categories']) && $categoryId) {diff --git a/app/component/product/categories.php b/app/component/product/categories.phpindex 2cb0533..2fca449 100644--- a/app/component/product/categories.php+++ b/app/component/product/categories.php@@ -32,6 +32,7 @@ class Categories extends ComponentBase {'start' => 0,'limit' => 7,'site_id' => NULL,+ 'language_id' => NULL,'order' => ['url', 'price asc'],'taxonomy_id' => NULL,'product_id' => NULL,@@ -39,6 +40,7 @@ class Categories extends ComponentBase {'search' => NULL,'type' => 'categories','post_type' => 'product',+ 'count' => false, //include number of products'parents_only' => false,'parents_children_only' => false,'parents_without_children' => false,@@ -47,8 +49,18 @@ class Categories extends ComponentBase {//public $cacheExpire = 0; //no cachefunction results() {+ if (isset($this->options['post_type']) && ! $this->options['post_type']) {+ unset($this->options['post_type']);+ }+$category = new \Vvveb\Sql\CategorySQL();+$results = $category->getCategories($this->options);+ $taxonomy_type = 'category';++ if (isset($this->options['type']) && $this->options['type'] == 'tags') {+ $taxonomy_type = 'tag';+ }//count the number of child categories (subcategories) for each categoryif (isset($results['categories'])) {@@ -60,16 +72,16 @@ class Categories extends ComponentBase {$category['children'] = 0;}- if (isset($this->options['post_type'])) {- $category['type'] = $this->options['post_type'];+ if (isset($this->options['post_type']) && $this->options['post_type']) {+ $category['post_type'] = $this->options['post_type'];}$url = ['slug' => $category['slug']];- if ($category['type'] != 'product') {- $url['post_type'] = $category['type'];+ if (isset($category['post_type']) && ($category['post_type'] != 'product')) {+ $url['type'] = $category['post_type'];}- $category['url'] = url('product/category/index', $url);+ $category['url'] = url('product/' . $taxonomy_type . '/index', $url);if (isset($category['image'])) {$category['image_url'] = Images::image($category['image'], 'taxonomy_item');diff --git a/app/template/components/product/categories.tpl b/app/template/components/product/categories.tplold mode 100755new mode 100644index 739c4ca..3676e71--- a/app/template/components/product/categories.tpl+++ b/app/template/components/product/categories.tpl@@ -52,6 +52,7 @@ $generate_menu = function ($parent) use (&$_categories, &$generate_menu, $vvveb_@category img[data-v-cat-*]|src = $category['@@__data-v-cat-(*)__@@']@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';?>diff --git a/app/template/product/tag.tpl b/app/template/product/tag.tplnew file mode 100644index 0000000..637eff2--- /dev/null+++ b/app/template/product/tag.tpl@@ -0,0 +1 @@+import(product/category.tpl)