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
Enable categories and tags for pages (page post type)
givanz8b9db6a408ba
diff --git a/admin/controller/content/edit.php b/admin/controller/content/edit.phpindex 8db8b7f..7e3d3ee 100644--- a/admin/controller/content/edit.php+++ b/admin/controller/content/edit.php@@ -301,12 +301,15 @@ class Edit extends Base {if ($template == $defaultTemplate) {$view->template_missing = sprintf(__('Template missing, choose existing template or %screate global template%s for %s.'), '<a href="' . $design_url . '" target="_blank">', '</a>', $type_name);} else {- $view->template_missing = sprintf(__('Template missing, %screate template%s for this %s.'), '<a href="' . $design_url . '" target="_blank">', '</a>', $type_name);+ $view->template_missing = sprintf(__('Template %s missing, %screate template%s for this %s.'), '<b>' . $template . '</b>', '<a href="' . $design_url . '" target="_blank">', '</a>', $type_name);}}- if ($this->type != 'page') {- $view->taxonomies = $this->taxonomies($post[$this->object . '_id'] ?? false);+ $view->taxonomies = $this->taxonomies($post[$this->object . '_id'] ?? false);++ if ($this->type == 'page') {+ //remove menu type+ unset($view->taxonomies[3]);}$sites = $post[$this->object . '_to_site'] ?? [];diff --git a/admin/controller/content/posts.php b/admin/controller/content/posts.phpindex 2056d98..9aaa18e 100755--- a/admin/controller/content/posts.php+++ b/admin/controller/content/posts.php@@ -251,7 +251,7 @@ class Posts extends Listing {$template = $post['template'] ? $post['template'] : $defaultTemplate;$post['url'] = url($url);$post['edit-url'] = $post['url'];- $post['admin-url'] = url(['module' => 'content/posts']) . '&filter[admin_id_text]=' . $post['username'] . ' &filter[admin_id]=' . $post['admin_id'];+ $post['admin-url'] = url(['module' => 'content/posts']) . '&type=' . $this->type . '&filter[admin_id_text]=' . $post['username'] . ' &filter[admin_id]=' . $post['admin_id'];$post['delete-url'] = url(['module' => 'content/posts', 'action' => 'delete'] + $url); // + ['post_id[]' => $post['post_id']]);$post['duplicate-url'] = url(['module' => 'content/posts', 'action' => 'duplicate'] + $url); // + ['post_id' => $post['post_id']]);$post['view-url'] = url("content/{$this->type}/index", $post + $url + ['host' => $this->global['host'], 'path' => $this->global['path'] ? '/' . $this->global['path'] : null]);diff --git a/admin/sql/mysqli/category.sql b/admin/sql/mysqli/category.sqlindex fb4f389..af9f660 100644--- a/admin/sql/mysqli/category.sql+++ b/admin/sql/mysqli/category.sql@@ -337,7 +337,16 @@@IF isset(:type)THEN- INNER JOIN taxonomy t ON (_.taxonomy_id = t.taxonomy_id AND t.type = :type)+ INNER JOIN taxonomy t ON (+ _.taxonomy_id = t.taxonomy_id AND t.type = :type++ @IF isset(:post_type)+ THEN++ AND t.post_type = :post_type++ END @IF+ )END @IFWHERE@@ -350,14 +359,6 @@END @IF- @IF isset(:post_type)- THEN-- AND _.post_type = :post_type-- END @IF--@IF isset(:post_id)THEN,pt.post_id as checkeddiff --git a/admin/sql/mysqli/comment.sql b/admin/sql/mysqli/comment.sqlold mode 100755new mode 100644index 4e7cf7f..823a88a--- a/admin/sql/mysqli/comment.sql+++ b/admin/sql/mysqli/comment.sql@@ -5,7 +5,6 @@CREATE PROCEDURE getAll(-- variablesIN language_id INT,- IN site_id INT,IN post_id INT,IN user_id INT,IN status INT,diff --git a/admin/sql/mysqli/order.sql b/admin/sql/mysqli/order.sqlold mode 100755new mode 100644index f11e2d0..dbd0aa8--- a/admin/sql/mysqli/order.sql+++ b/admin/sql/mysqli/order.sql@@ -4,9 +4,9 @@CREATE PROCEDURE getAll(-- variables- IN language_id INT,- IN site_id INT,- IN user_id INT+ IN language_id INT,+ IN site_id INT,+ IN user_id INTIN order_status CHAR,IN order_status_id INT,diff --git a/admin/sql/mysqli/user_address.sql b/admin/sql/mysqli/user_address.sqlindex e9d1f75..f7fab47 100755--- a/admin/sql/mysqli/user_address.sql+++ b/admin/sql/mysqli/user_address.sql@@ -4,8 +4,7 @@CREATE PROCEDURE getAll(-- variables- IN site_id INT,- IN user_id INT,+ IN user_id INT,-- paginationIN start INT,@@ -119,7 +118,7 @@-- Delete user addressCREATE PROCEDURE delete(- IN user_address_id ARRAY,+ IN user_address_id ARRAY,IN user_id INT,OUT affected_rows)diff --git a/admin/sql/sqlite/category.sql b/admin/sql/sqlite/category.sqlindex 9d00b10..00b22e2 100644--- a/admin/sql/sqlite/category.sql+++ b/admin/sql/sqlite/category.sql@@ -335,7 +335,16 @@@IF isset(:type)THEN- INNER JOIN taxonomy t ON (_.taxonomy_id = t.taxonomy_id AND t.type = :type)+ INNER JOIN taxonomy t ON (+ _.taxonomy_id = t.taxonomy_id AND t.type = :type++ @IF isset(:post_type)+ THEN++ AND t.post_type = :post_type++ END @IF+ )END @IFWHERE@@ -348,13 +357,6 @@END @IF- @IF isset(:post_type)- THEN-- AND _.post_type = :post_type-- END @IF-@IF isset(:post_id)THEN,pt.post_id as checkeddiff --git a/admin/template/content/post_taxonomy.tpl b/admin/template/content/post_taxonomy.tplindex 36fcd66..62445a9 100755--- a/admin/template/content/post_taxonomy.tpl+++ b/admin/template/content/post_taxonomy.tpl@@ -18,6 +18,9 @@ if(isset($this->taxonomies) && is_array($this->taxonomies)) {@taxonomy_item [data-v-taxonomy_item-url]|title = $taxonomy_item['name']@taxonomy_item a[data-v-edit-url]|href = <?php echo \Vvveb\url(['module' => 'content/taxonomy_item', 'taxonomy_id' => $taxonomyItem['taxonomy_id']]);?>++ @taxonomy_item [data-v-taxonomy_item-label]|for = <?php echo 't-' . $taxonomy_item['taxonomy_id'];?>+ @taxonomy_item [data-v-taxonomy_item-input]|id = <?php echo 't-' . $taxonomy_item['taxonomy_id'];?>@taxonomy_item|after = <?phpdiff --git a/app/component/breadcrumb.php b/app/component/breadcrumb.phpindex da73d11..8d3a39e 100644--- a/app/component/breadcrumb.php+++ b/app/component/breadcrumb.php@@ -90,7 +90,8 @@ class Breadcrumb extends ComponentBase {+ self :: $global);if ($result && isset($result['taxonomy_item_id'])) {- $breadcrumb[] = ['text' => $result['name'], 'url' => url('product/category/index', $result + $urlOptions)];+ $cat = ['slug' => $result['slug']];+ $breadcrumb[] = ['text' => $result['name'], 'url' => url('product/category/index', $cat + $urlOptions)];}}@@ -141,7 +142,8 @@ class Breadcrumb extends ComponentBase {+ self :: $global);if ($result && isset($result['taxonomy_item_id'])) {- $breadcrumb[] = ['text' => $result['name'], 'url' => url('content/category/index', $result + $urlOptions)];+ $cat = ['slug' => $result['slug']];+ $breadcrumb[] = ['text' => $result['name'], 'url' => url('content/category/index', $cat + $urlOptions)];}}@@ -150,7 +152,19 @@ class Breadcrumb extends ComponentBase {break;case 'content/page/index':- $post_id = $request->get['post_id'] ?? false;+ $post_id = $request->get['post_id'] ?? false;++ if ($post_id) {+ $category = new CategorySQL();+ $result = $category->getCategory(+ ['post_id' => $post_id, 'limit' => 1, 'type' => 'categories', 'post_type' => 'page']+ + self :: $global);++ if ($result && isset($result['taxonomy_item_id'])) {+ $cat = ['slug' => $result['slug'], 'type' => 'page'];+ $breadcrumb[] = ['text' => $result['name'], 'url' => url('content/category/index', $cat + $urlOptions)];+ }+ }$breadcrumb[] = ['text' => $name, 'url' => false];diff --git a/app/controller/content/category.php b/app/controller/content/category.phpindex c6f7a8b..5a3f442 100755--- a/app/controller/content/category.php+++ b/app/controller/content/category.php@@ -37,7 +37,11 @@ class Category extends Base {if ($slug) {$categorySql = new CategorySQL();- $options = $this->global + ['slug' => $slug/*, 'post_type' => $type*/];+ $options = $this->global + ['slug' => $slug];+ if ($type) {+ $options['post_type'] = $type;+ }+$category = $categorySql->getCategoryBySlug($options);if ($category) {@@ -56,6 +60,15 @@ class Category extends Base {$this->request->get['taxonomy_item_id'] = $category['taxonomy_item_id'];$this->request->get['slug'] = $category['slug'];$this->view->category = $category;++ if ($type != 'post') {+ //content/category-page.html+ $template = 'content/' . $this->type . '-' . $type . '.html';+ if ($template) {+ $this->view->template($template);+ $this->view->tplFile('content/' . $this->type . '.tpl');+ }+ }} else {$message = sprintf(__('%s not found!'), ucfirst(__($this->type)));$this->notFound(true, ['message' => $message, 'title' => $message]);diff --git a/app/controller/product/category.php b/app/controller/product/category.phpindex c4148e7..a279841 100755--- a/app/controller/product/category.php+++ b/app/controller/product/category.php@@ -37,7 +37,11 @@ class Category extends Base {if ($slug) {$categorySql = new CategorySQL();- $options = $this->global + ['slug' => $slug/*, 'post_type' => $type*/];+ $options = $this->global + ['slug' => $slug];+ if ($type) {+ $options['post_type'] = $type;+ }+$category = $categorySql->getCategoryBySlug($options);if ($category) {@@ -56,6 +60,15 @@ class Category extends Base {$this->request->get['taxonomy_item_id'] = $category['taxonomy_item_id'];$this->request->get['slug'] = $category['slug'];$this->view->category = $category;++ if ($type != 'product') {+ //product/category-page.html+ $template = 'product/' . $this->type . '-' . $type . '.html';+ if ($template) {+ $this->view->template($template);+ $this->view->tplFile('product/' . $this->type . '.tpl');+ }+ }} else {$message = sprintf(__('%s not found!'), ucfirst(__($this->type)));$this->notFound(true, ['message' => $message, 'title' => $message]);diff --git a/app/sql/mysqli/category.sql b/app/sql/mysqli/category.sqlindex e0d3ddf..d65a2c1 100644--- a/app/sql/mysqli/category.sql+++ b/app/sql/mysqli/category.sql@@ -111,7 +111,16 @@@IF isset(:type)THEN- INNER JOIN taxonomy t ON (_.taxonomy_id = t.taxonomy_id AND t.type = :type)+ INNER JOIN taxonomy t ON (+ _.taxonomy_id = t.taxonomy_id AND t.type = :type++ @IF isset(:post_type)+ THEN++ AND t.post_type = :post_type++ END @IF+ )END @IFWHERE@@ -128,7 +137,7 @@THENAND _.taxonomy_item_id = :taxonomy_item_idEND @IF-+@IF isset(:post_id)THENAND pt.post_id = :post_iddiff --git a/config/admin-menu.php b/config/admin-menu.phpindex d2f6dca..60ead08 100755--- a/config/admin-menu.php+++ b/config/admin-menu.php@@ -183,6 +183,21 @@ return'action' => 'index','icon' => 'la la-boxes',],+ 'categories' => [+ 'name' => __('Categories'),+ 'url' => $admin_path . '?module=content/categories&taxonomy_id=6',+ 'module' => 'content/categories',+ 'action' => 'index',+ 'icon' => 'la la-boxes',+ ],++ 'tags' => [+ 'name' => __('Tags'),+ 'url' => $admin_path . '?module=content/categories&taxonomy_id=7',+ 'module' => 'content/categories',+ 'action' => 'index',+ 'icon' => 'la la-tags',+ ],/*'categories' =>[diff --git a/config/app-routes.php b/config/app-routes.phpindex 1477c2f..6f18046 100755--- a/config/app-routes.php+++ b/config/app-routes.php@@ -135,11 +135,19 @@ return [//content'/blog' => ['module' => 'content'],'/blog/#page#' => ['module' => 'content'],+ //post taxonomy'/cat/{slug}' => ['module' => 'content/category/index'],'/cat/{slug}/#page#' => ['module' => 'content/category/index'],- '/tag/{slug}' => ['module' => 'content/tag/index'],- '/tag/{slug}/#page#' => ['module' => 'content/tag/index'],- '/author/{username}' => ['module' => 'content/user/index'],+ '/t/{slug}' => ['module' => 'content/tag/index'],+ '/t/{slug}/#page#' => ['module' => 'content/tag/index'],+ //page taxonomy+ //post taxonomy+ '/category/{slug}' => ['module' => 'content/category/index', 'type' => 'page'],+ '/category/{slug}/#page#' => ['module' => 'content/category/index', 'type' => 'page'],+ '/tag/{slug}' => ['module' => 'content/tag/index', 'type' => 'page'],+ '/tag/{slug}/#page#' => ['module' => 'content/tag/index', 'type' => 'page'],++ '/author/{username}' => ['module' => 'content/user/index'],//archive year'/#year{4,4}#'=> ['module' => 'content/archive/index'],//archive month and year@@ -162,8 +170,17 @@ return ['/{language{2,3}}/p/#page#' => ['module' => 'index/index'],//content'/{language{2,3}}/blog' => ['module' => 'content'],+ //post taxonomy'/{language{2,3}}/cat/{slug}' => ['module' => 'content/category/language'],- '/{language{2,3}}/tag/{slug}' => ['module' => 'content/tag/index'],+ '/{language{2,3}}/cat/{slug}/#page#' => ['module' => 'content/category/language'],+ '/{language{2,3}}/t/{slug}' => ['module' => 'content/tag/index'],+ '/{language{2,3}}/t/{slug}/#page#' => ['module' => 'content/tag/index'],+ //page taxonomy+ '/{language{2,3}}/category/{slug}' => ['module' => 'content/category/language', 'type' => 'page'],+ '/{language{2,3}}/category/{slug}/#page#' => ['module' => 'content/category/language', 'type' => 'page'],+ '/{language{2,3}}/tag/{slug}' => ['module' => 'content/tag/index', 'type' => 'page'],+ '/{language{2,3}}/tag/{slug}/#page#' => ['module' => 'content/tag/index', 'type' => 'page'],+ //post//'/{language{2,3}}/{slug}-#post_id#' => ['module' => 'content/post/index', 'edit'=>'?module=content/post&post_id={post_id}'],'/{language{2,3}}/p-#post_id#' => ['module' => 'content/post/index', 'edit'=>'?module=content/post&post_id=#post_id#'],'/{language{2,3}}/{slug}' => ['module' => 'content/post/index', 'edit'=>'?module=content/post&slug={slug}'],@@ -185,7 +202,7 @@ return ['/{language{2,3}}/checkout' => ['module' => 'checkout/checkout/index'],'/{language{2,3}}/user' => ['module' => 'user/index'],*/-+//custom post'/{type}' => ['module' => 'content'],'/{type}/#page#' => ['module' => 'content'],diff --git a/system/routes.php b/system/routes.phpindex 2b706df..640e6d6 100755--- a/system/routes.php+++ b/system/routes.php@@ -45,6 +45,8 @@ class Routes {private static function processRoute($url, $data) {$module = $data['module'];+ unset($data['edit'], $data['module']);+//self :: $modules[$module] = $url;$parameters = [];@@ -55,6 +57,10 @@ class Routes {}}+ if ($data) {+ $parameters = array_merge($parameters, array_keys($data));+ }+self :: $modules[$module][] = ['url' => $url, 'parameters' => $parameters, 'count' => count($parameters)];//add urls with most parameters first for proper matchinguasort(self :: $modules[$module], function ($a, $b) {@@ -107,7 +113,7 @@ class Routes {public static function init($app = 'app', $site_id = null) {$cacheDriver = Cache :: getInstance();- if ($site_id) {+ if ($site_id) {$cacheKey = $site_id;} else {$cacheKey = $app;@@ -119,12 +125,12 @@ class Routes {static::$modules = $result['modules'];} else {$routesConfig = DIR_ROOT . '/config/';- if ($site_id) {+ if ($site_id) {$routesConfig .= "site-$site_id-routes.php";} else {$routesConfig .= "$app-routes.php";}-+if (file_exists($routesConfig)) {self :: $routes += include $routesConfig;}diff --git a/system/traits/crud.php b/system/traits/crud.phpindex c08fda0..00ee8b7 100644--- a/system/traits/crud.php+++ b/system/traits/crud.php@@ -93,11 +93,11 @@ trait Crud {function save() {$type = $this->type;- $type_id = "{$type}_id";$module = $this->module;$controller = $this->controller ?? $type;$result = [];+ $type_id = $this->type_id ?? "{$type}_id";$this->data_id = $this->request->get[$type_id] ?? false;if (isset($this->fullPost) && $this->fullPost) {@@ -140,13 +140,13 @@ trait Crud {}if ($result && isset($result[$type])) {- $successMessage = humanReadable(__($type)) . __(' saved!');+ $successMessage = humanReadable(__($type)) . __(' saved!');$this->view->success['get'] = $successMessage;$this->session->set('success', ['get' => $successMessage]);if (! $this->data_id && $this->redirect) {if ($this->redirect === true) {- $this->redirect(['module' => "$module/$controller", $type_id => $result[$type], 'success' => $successMessage]);+ $this->redirect(['module' => "$module/$controller", $type_id => $result[$type], 'success' => $successMessage]);} else {$this->redirect($this->redirect . "?$type_id={$result[$type]}&success=$successMessage");}