Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Fixed component content saving

givanz8735000746f3
diff --git a/app/component/post.php b/app/component/post.php
index d95ec4a..b3c636e 100755
--- a/app/component/post.php
+++ b/app/component/post.php
@@ -111,6 +111,7 @@ class Post extends ComponentBase {
$posts = new PostSQL();
$publicPath = \Vvveb\publicUrlPath() . 'media/';
+ $post = [];
$post_content = [];
foreach ($fields as $field) {
@@ -134,11 +135,16 @@ class Post extends ComponentBase {
}
}
}
- //$post['post_content']['post_id'] = $id;
- $post_content['language_id'] = 1;
- $post['post_content'][] = $post_content;
- $post['post_id'] = $id;
- $result = $posts->edit(['post' => $post, 'post_id' => $id]);
+ if ($post) {
+ //$post['post_id'] = $id;
+ $result = $posts->edit(['post' => $post, 'post_id' => $id]);
+ }
+
+ if ($post_content) {
+ $post_content['language_id'] = self :: $global['language_id'];
+ //$post['post_content']['post_id'] = $id;
+ $result = $posts->editContent(['post_content' => $post_content, 'post_id' => $id, 'language_id' => self :: $global['language_id']]);
+ }
}
}
diff --git a/app/component/product.php b/app/component/product.php
index f5e5a52..edb1f19 100755
--- a/app/component/product.php
+++ b/app/component/product.php
@@ -125,6 +125,9 @@ class Product extends ComponentBase {
$product_content = [];
$publicPath = \Vvveb\publicUrlPath() . 'media/';
+ $product = [];
+ $product_content = [];
+
foreach ($fields as $field) {
$name = $field['name'];
$value = $field['value'];
@@ -132,20 +135,29 @@ class Product extends ComponentBase {
if ($name == 'name') {
$product_content[$name] = strip_tags($value);
} else {
- if ($name == 'content' || $name == 'excerpt') {
- $product_content[$name] = sanitizeHTML($value);
+ if ($name == 'images') {
} else {
- if ($name == 'image') {
- $value = str_replace($publicPath,'', $value);
+ if ($name == 'content' || $name == 'excerpt') {
+ $product_content[$name] = sanitizeHTML($value);
+ } else {
+ if ($name == 'image') {
+ $value = str_replace($publicPath,'', $value);
+ }
+ $product[$name] = $value;
}
- $product[$name] = $value;
}
}
}
- $product_content['language_id'] = 1;
- $product['product_content'][] = $product_content;
- $product['product_id'] = $id;
- $result = $products->edit(['product' => $product, 'product_id' => $id]);
+ if ($product) {
+ //$product['product_id'] = $id;
+ $result = $products->edit(['product' => $product, 'product_id' => $id]);
+ }
+
+ if ($product_content) {
+ $product_content['language_id'] = self :: $global['language_id'];
+ //$product['product_content']['post_id'] = $id;
+ $result = $products->editContent(['product_content' => $product_content, 'product_id' => $id, 'language_id' => self :: $global['language_id']]);
+ }
}
}