Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Fixed category save

givanzbf588e9b09ad
diff --git a/admin/controller/content/categories.php b/admin/controller/content/categories.php
index 2173939..0a036c3 100755
--- a/admin/controller/content/categories.php
+++ b/admin/controller/content/categories.php
@@ -55,9 +55,11 @@ class Categories extends Base {
die(0);
}
- function add() {
+ function save() {
$data = $this->request->post;
$data['taxonomy_id'] = $data['taxonomy_id'] ?? $this->request->get['taxonomy_id'];
+ $data['taxonomy_item']['taxonomy_id'] = $data['taxonomy_id'];
+ $data['taxonomy_item']['sort_order'] = $data['sort_order'] ?? 0;
$categories = new categorySQL();
diff --git a/admin/sql/pgsql/category.sql b/admin/sql/pgsql/category.sql
index 0a2e5f4..dcae55b 100755
--- a/admin/sql/pgsql/category.sql
+++ b/admin/sql/pgsql/category.sql
@@ -65,12 +65,12 @@
@IF isset(:post_id) THEN
@IF :type == "tags"
- THEN
-
- INNER JOIN post_to_taxonomy_item pt ON (categories.taxonomy_item_id = pt.taxonomy_item_id AND pt.post_id = :post_id)
- @ELSE
-
- LEFT JOIN post_to_taxonomy_item pt ON (categories.taxonomy_item_id = pt.taxonomy_item_id AND pt.post_id = :post_id)
+ THEN
+
+ INNER JOIN post_to_taxonomy_item pt ON (categories.taxonomy_item_id = pt.taxonomy_item_id AND pt.post_id = :post_id)
+ @ELSE
+
+ LEFT JOIN post_to_taxonomy_item pt ON (categories.taxonomy_item_id = pt.taxonomy_item_id AND pt.post_id = :post_id)
END @IF
@@ -107,7 +107,7 @@
AND t.type = :type
END @IF
-
+
@IF isset(:post_type)
THEN
@@ -167,6 +167,7 @@
IN parent_id INT,
IN search CHAR,
IN type CHAR,
+ IN post_type CHAR,
-- pagination
IN start INT,
@@ -196,7 +197,23 @@
FROM post_content pc
LEFT JOIN post p ON (pc.post_id = p.post_id)
LEFT JOIN post_to_taxonomy_item ptt ON (ptt.taxonomy_item_id = categories.taxonomy_item_id AND ptt.post_id = p.post_id)
- WHERE ptt.taxonomy_item_id = categories.taxonomy_item_id ORDER BY p.sort_order
+ WHERE ptt.taxonomy_item_id = categories.taxonomy_item_id
+
+ @IF isset(:post_type)
+ THEN
+
+ AND p.type = :post_type
+
+ END @IF
+
+
+ ORDER by p.sort_order
+
+ @IF isset(:posts_limit) && !empty(:posts_limit)
+ THEN
+ @SQL_LIMIT(:posts_start, :posts_limit)
+ END @IF
+
) AS post
FROM taxonomy_item AS categories
@@ -261,7 +278,7 @@
THEN
@SQL_LIMIT(:start, :limit)
END @IF
- ;
+ ;
SELECT count(*) FROM (
@@ -316,7 +333,7 @@
END @IF
- WHERE
+ WHERE
1 = 1
@IF isset(:taxonomy_item_id)
@@ -332,7 +349,7 @@
AND _.post_type = :post_type
END @IF
-
+
@IF isset(:post_id)
THEN
,pt.post_id as checked
@@ -363,6 +380,7 @@
IN taxonomy_item_id INT,
IN parent_id INT,
IN language_id INT,
+ IN site_id INT,
IN post_type CHAR,
IN slug CHAR,
OUT fetch_row
@@ -374,6 +392,12 @@
FROM taxonomy_item_content AS _
LEFT JOIN taxonomy_item as ti ON (_.taxonomy_item_id = ti.taxonomy_item_id)
LEFT JOIN taxonomy t ON (ti.taxonomy_id = t.taxonomy_id)
+
+ @IF isset(:site_id)
+ THEN
+ LEFT JOIN taxonomy_to_site tt ON (tt.taxonomy_item_id = ti.taxonomy_item_id)
+ END @IF
+
WHERE 1 = 1
@IF isset(:taxonomy_item_id)
@@ -409,9 +433,16 @@
AND t.post_type = :post_type
+ END @IF
+
+ @IF isset(:site_id)
+ THEN
+
+ AND tt.site_id = :site_id
+
END @IF
-
+
LIMIT 1;
-- images
diff --git a/admin/template/content/tags.tpl b/admin/template/content/tags.tpl
old mode 100755
new mode 100644
index 68c193f..daf9e1e
--- a/admin/template/content/tags.tpl
+++ b/admin/template/content/tags.tpl
@@ -12,6 +12,7 @@ if(isset($this->categories) && is_array($this->categories)) {
@tag [data-v-*]|title = $tag['@@__data-v-(*)__@@']
@tag [data-v-*]|innerText = $tag['@@__data-v-(*)__@@']
@tag input[data-v-*]|value = $tag['@@__data-v-(*)__@@']
+ @tag button[data-v-*]|value = $tag['@@__data-v-(*)__@@']
@tag a[data-v-*]|href = $tag['@@__data-v-(*)__@@']
@tag img[data-v-image_url]|src = $tag['image_url']
diff --git a/admin/template/product/categories.tpl b/admin/template/product/categories.tpl
index 756bb8f..5cc2a09 100755
--- a/admin/template/product/categories.tpl
+++ b/admin/template/product/categories.tpl
@@ -31,6 +31,12 @@ if ($_categories) {
@taxonomy_item|before = <?php
foreach($_categories as $id => $taxonomy_item) {
+ $taxonomy_id = 'taxonomy-' . $taxonomy_item['taxonomy_item_id'];
+ $taxonomy_input = "taxonomy-{$taxonomy_item['taxonomy_item_id']}-input";
+
+ $taxonomy_hash = "#$taxonomy_id";
+ $taxonomy_input_hash = "#$taxonomy_input";
+
$uniq = Vvveb\System\Functions\Str::random(5);
if ($taxonomy_item['parent_id'] == $parent) {?>
@@ -39,6 +45,21 @@ if ($_categories) {
@taxonomy_item [data-v-taxonomy_item-url]|href = <?php echo htmlspecialchars(Vvveb\url('post/taxonomy_item/index', $taxonomy_item));?>
@taxonomy_item [data-v-taxonomy_item-img]|src = $taxonomy_item['images'][0]
+
+ @taxonomy_item [data-v-image] = $taxonomy_item['image']
+ @taxonomy_item [data-v-image-src]|src = $taxonomy_item['image_url']
+ @taxonomy_item [data-v-image-src]|id = $taxonomy_id
+
+ @taxonomy_item [data-v-image-src]|data-target-input = $taxonomy_input_hash
+ @taxonomy_item [data-v-image-src]|data-target-thumb = $taxonomy_hash
+
+ @taxonomy_item [data-v-image-btn]|data-target-input = $taxonomy_input_hash
+ @taxonomy_item [data-v-image-btn]|data-target-thumb = $taxonomy_hash
+
+
+ @taxonomy_item .taxonomy_input = $taxonomy_item['image']
+ @taxonomy_item .taxonomy_input|data-target-input = $taxonomy_input_hash
+ @taxonomy_item .taxonomy_input|id = $taxonomy_input
@taxonomy_item|append = <?php
$generate_menu($taxonomy_item['taxonomy_item_id'], $_categories);
@@ -85,5 +106,4 @@ foreach ($languages as $key => $language) {
@language|after = <?php
$_i++;
}
-?>
-
+?>
\ No newline at end of file