Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Set category title for seo

givanze818227a6010
diff --git a/app/controller/content/category.php b/app/controller/content/category.php
index f2dcf4c..c6f7a8b 100755
--- a/app/controller/content/category.php
+++ b/app/controller/content/category.php
@@ -25,29 +25,37 @@ namespace Vvveb\Controller\Content;
use function Vvveb\__;
use Vvveb\Controller\Base;
use Vvveb\Sql\CategorySQL;
+use Vvveb\System\Images;
class Category extends Base {
protected $type = 'category';
function index() {
- $category_name = $this->request->get['slug'] ?? '';
- $type = $this->request->get['type'] ?? '';
- $this->view->category_name = $category_name;
+ $slug = $this->request->get['slug'] ?? '';
+ $type = $this->request->get['type'] ?? 'post';
+ $this->view->category_name = $slug;
- if ($category_name) {
+ if ($slug) {
$categorySql = new CategorySQL();
- $options = $this->global + ['slug' => $category_name];
+ $options = $this->global + ['slug' => $slug/*, 'post_type' => $type*/];
+ $category = $categorySql->getCategoryBySlug($options);
- if ($type) {
- $options['post_type'] = $type;
- }
+ if ($category) {
+ $this->request->get['category_id'] = $this->request->request['taxonomy_item_id'] = $category['taxonomy_item_id'];
+ $this->request->get['name'] = $category['name'];
- $category = $categorySql->getCategory($options);
+ if (isset($category['image']) && $category['image']) {
+ $category['image_url'] = Images::image($category['image'], 'product', 'medium');
+ }
+
+ $category['title'] = $category['name'];
+ if (isset($this->global['site']['description']['title'])) {
+ $category['title'] = $category['title'] . ' - ' . $this->global['site']['description']['title'];
+ }
- if ($category) {
$this->request->get['taxonomy_item_id'] = $category['taxonomy_item_id'];
$this->request->get['slug'] = $category['slug'];
- $this->view->category_name = $category['name'];
+ $this->view->category = $category;
} 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.php
index 8881ab4..c4148e7 100755
--- a/app/controller/product/category.php
+++ b/app/controller/product/category.php
@@ -25,30 +25,40 @@ namespace Vvveb\Controller\Product;
use \Vvveb\Sql\CategorySQL;
use function Vvveb\__;
use Vvveb\Controller\Base;
+use Vvveb\System\Images;
class Category extends Base {
+ protected $type = 'category';
+
function index() {
$slug = $this->request->get['slug'] ?? '';
- $type = $this->request->get['type'] ?? '';
+ $type = $this->request->get['type'] ?? 'product';
$this->view->category_name = $slug;
if ($slug) {
$categorySql = new CategorySQL();
- $options = $this->global + ['slug' => $slug/*, 'post_type' => 'product'*/];
-
- if ($type) {
- $options['post_type'] = $type;
- }
-
+ $options = $this->global + ['slug' => $slug/*, 'post_type' => $type*/];
$category = $categorySql->getCategoryBySlug($options);
if ($category) {
- $this->request->get['category_id'] = $this->request->request['taxonomy_item_id'] = $category['taxonomy_item_id'];
- $this->view->category = $category;
- $this->view->category_name = $category['name'];
+ $this->request->get['category_id'] = $this->request->request['taxonomy_item_id'] = $category['taxonomy_item_id'];
+ $this->request->get['name'] = $category['name'];
+
+ if (isset($category['image']) && $category['image']) {
+ $category['image_url'] = Images::image($category['image'], 'product', 'medium');
+ }
+
+ $category['title'] = $category['name'];
+ if (isset($this->global['site']['description']['title'])) {
+ $category['title'] = $category['title'] . ' - ' . $this->global['site']['description']['title'];
+ }
+
+ $this->request->get['taxonomy_item_id'] = $category['taxonomy_item_id'];
+ $this->request->get['slug'] = $category['slug'];
+ $this->view->category = $category;
} else {
- $message = __('Category not found!');
- $this->notFound(true, $message);
+ $message = sprintf(__('%s not found!'), ucfirst(__($this->type)));
+ $this->notFound(true, ['message' => $message, 'title' => $message]);
}
}
}
diff --git a/app/controller/product/index.php b/app/controller/product/index.php
index 3065f2c..9d0670d 100755
--- a/app/controller/product/index.php
+++ b/app/controller/product/index.php
@@ -28,5 +28,7 @@ use Vvveb\System\Core\View;
class Index extends Base {
function index() {
$view = View::getInstance();
+ $view->order_by = $this->request->get['order_by'] ?? false;
+ $view->direction = $this->request->get['direction'] ?? false;
}
}
diff --git a/app/controller/product/manufacturer.php b/app/controller/product/manufacturer.php
index 95b0c99..597924c 100755
--- a/app/controller/product/manufacturer.php
+++ b/app/controller/product/manufacturer.php
@@ -25,6 +25,7 @@ namespace Vvveb\Controller\Product;
use \Vvveb\Sql\ManufacturerSQL;
use function Vvveb\__;
use Vvveb\Controller\Base;
+use Vvveb\System\Images;
class Manufacturer extends Base {
function index() {
@@ -37,6 +38,18 @@ class Manufacturer extends Base {
$manufacturer = $manufacturerSql->get($options);
if ($manufacturer) {
+ $this->request->get['name'] = $manufacturer['name'];
+
+ if (isset($manufacturer['image'])) {
+ $manufacturer['image_url'] = Images::image($manufacturer['image'], 'manufacturer');
+ }
+
+
+ $manufacturer['title'] = $manufacturer['name'];
+ if (isset($this->global['site']['description']['title'])) {
+ $manufacturer['title'] = $manufacturer['title'] . ' - ' . $this->global['site']['description']['title'];
+ }
+
$this->request->request['manufacturer_id'] = $manufacturer['manufacturer_id'];
$this->view->manufacturer = $manufacturer;
$this->view->manufacturer_name = $manufacturer['name'];
diff --git a/app/controller/product/product.php b/app/controller/product/product.php
index a8440e0..60dbb46 100755
--- a/app/controller/product/product.php
+++ b/app/controller/product/product.php
@@ -62,7 +62,8 @@ class Product extends Base {
list($content, $language, $slug) = Event :: trigger(__CLASS__,__FUNCTION__, $content, $language, $slug);
- $error = __('Product not found!');
+ $error = __('Product not found!');
+ $languageContent = [];
if ($content) {
if (isset($content[$language])) {
@@ -103,13 +104,18 @@ class Product extends Base {
$this->notFound(true, ['message' => $error, 'title' => $error]);
}
+ $languageContent['title'] = $languageContent['name'];
+ if (isset($this->global['site']['description']['title'])) {
+ $languageContent['title'] = $languageContent['title'] . ' - ' . $this->global['site']['description']['title'];
+ }
+
list($content, $languageContent, $language, $slug) = Event :: trigger(__CLASS__,__FUNCTION__ . ':after', $content, $languageContent, $language, $slug);
} else {
$this->notFound(true, ['message' => $error, 'title' => $error]);
}
- $this->view->product = $languageContent;
- $this->view->content = $content;
+ $this->view->product = $languageContent;
+ $this->view->content = $content;
}
}
}
diff --git a/app/controller/product/vendor.php b/app/controller/product/vendor.php
old mode 100755
new mode 100644
index 6211f88..5efca4a
--- a/app/controller/product/vendor.php
+++ b/app/controller/product/vendor.php
@@ -38,10 +38,16 @@ class Vendor extends Base {
$vendor = $vendorSql->get($options);
if ($vendor) {
+ $this->request->get['name'] = $vendor['name'];
if (isset($vendor['image'])) {
$vendor['image_url'] = Images::image($vendor['image'], 'vendor');
}
+ $vendor['title'] = $vendor['name'];
+ if (isset($this->global['site']['description']['title'])) {
+ $vendor['title'] = $vendor['title'] . ' - ' . $this->global['site']['description']['title'];
+ }
+
$this->request->request['vendor_id'] = $vendor['vendor_id'];
$this->view->vendor = $vendor;
} else {
diff --git a/app/template/content/category.tpl b/app/template/content/category.tpl
old mode 100755
new mode 100644
index 1c55634..7ab9dc9
--- a/app/template/content/category.tpl
+++ b/app/template/content/category.tpl
@@ -1,5 +1,5 @@
import(common.tpl)
-head > title = <?php echo htmlspecialchars(ucfirst($this->category_name));?>
-
-[data-v-category-name] = <?php echo htmlspecialchars(ucfirst($this->category_name));?>
\ No newline at end of file
+head > title = $this->category['title']
+[data-v-category-*]|innerText = $this->category['@@__data-v-category-(*)__@@']
+img[data-v-category-*]|src = $this->category['@@__data-v-category-(*)__@@']
\ No newline at end of file
diff --git a/app/template/content/page.tpl b/app/template/content/page.tpl
old mode 100755
new mode 100644
index dcee482..e282a1b
--- a/app/template/content/page.tpl
+++ b/app/template/content/page.tpl
@@ -1,7 +1 @@
-import(common.tpl)
-
-head > title = $this->post['name']
-head > meta[name="keywords"]|content = $this->post['meta_keywords']
-head > meta[name="description"]|content = $this->post['meta_description']
-
-//body|append = <?php var_dump($this->post);?>
\ No newline at end of file
+import(content/post.tpl)
\ No newline at end of file
diff --git a/app/template/content/post.tpl b/app/template/content/post.tpl
old mode 100755
new mode 100644
index dcee482..7b6eac2
--- a/app/template/content/post.tpl
+++ b/app/template/content/post.tpl
@@ -1,7 +1,5 @@
import(common.tpl)
-head > title = $this->post['name']
-head > meta[name="keywords"]|content = $this->post['meta_keywords']
-head > meta[name="description"]|content = $this->post['meta_description']
-
-//body|append = <?php var_dump($this->post);?>
\ No newline at end of file
+head > title = $this->post['title']
+head > meta[name="keywords"]|content = $this->post['meta_keywords']
+head > meta[name="description"]|content = $this->post['meta_description']
\ No newline at end of file
diff --git a/app/template/content/tag.tpl b/app/template/content/tag.tpl
new file mode 100644
index 0000000..a140be5
--- /dev/null
+++ b/app/template/content/tag.tpl
@@ -0,0 +1 @@
+import(category.tpl)
\ No newline at end of file
diff --git a/app/template/product/category.tpl b/app/template/product/category.tpl
old mode 100755
new mode 100644
index 1c55634..7ab9dc9
--- a/app/template/product/category.tpl
+++ b/app/template/product/category.tpl
@@ -1,5 +1,5 @@
import(common.tpl)
-head > title = <?php echo htmlspecialchars(ucfirst($this->category_name));?>
-
-[data-v-category-name] = <?php echo htmlspecialchars(ucfirst($this->category_name));?>
\ No newline at end of file
+head > title = $this->category['title']
+[data-v-category-*]|innerText = $this->category['@@__data-v-category-(*)__@@']
+img[data-v-category-*]|src = $this->category['@@__data-v-category-(*)__@@']
\ No newline at end of file
diff --git a/app/template/product/manufacturer.tpl b/app/template/product/manufacturer.tpl
old mode 100755
new mode 100644
index 690ce79..6e54b24
--- a/app/template/product/manufacturer.tpl
+++ b/app/template/product/manufacturer.tpl
@@ -1,9 +1,6 @@
import(common.tpl)
-head > title = <?php echo htmlspecialchars(ucfirst($this->manufacturer_name));?>
-
-[data-v-manufacturer-name] = <?php echo htmlspecialchars(ucfirst($this->manufacturer_name));?>
-
+head > title = $this->manufacturer['title']
[data-v-manufacturer-*]|innerText = $this->manufacturer['@@__data-v-manufacturer-(*)__@@']
img[data-v-manufacturer-*]|src = $this->manufacturer['@@__data-v-manufacturer-(*)__@@']
-[data-v-manufacturer-name] = <?php echo htmlspecialchars(ucfirst($this->manufacturer['name'] ?? ''));?>
+[data-v-manufacturer-name] = <?php echo htmlspecialchars(ucfirst($this->manufacturer['name'] ?? ''));?>
\ No newline at end of file
diff --git a/app/template/product/product.tpl b/app/template/product/product.tpl
old mode 100755
new mode 100644
index 605568a..2fbe1de
--- a/app/template/product/product.tpl
+++ b/app/template/product/product.tpl
@@ -1,7 +1,5 @@
import(common.tpl)
-head > title = $this->product['name']
-head > meta[name="keywords"]|content = $this->product['meta_keywords']
-head > meta[name="description"]|content = $this->product['meta_description']
-
-//body|append = <?php var_dump($this->product);?>
+head > title = $this->product['title']
+head > meta[name="keywords"]|content = $this->product['meta_keywords']
+head > meta[name="description"]|content = $this->product['meta_description']
\ No newline at end of file
diff --git a/app/template/product/vendor.tpl b/app/template/product/vendor.tpl
old mode 100755
new mode 100644
index aeb6adb..fd7b11e
--- a/app/template/product/vendor.tpl
+++ b/app/template/product/vendor.tpl
@@ -1,7 +1,6 @@
import(common.tpl)
-head > title = <?php echo htmlspecialchars(ucfirst($this->vendor_name));?>
-
+head > title = $this->vendor['title']
[data-v-vendor-*]|innerText = $this->vendor['@@__data-v-vendor-(*)__@@']
img[data-v-vendor-*]|src = $this->vendor['@@__data-v-vendor-(*)__@@']
[data-v-vendor-name] = <?php echo htmlspecialchars(ucfirst($this->vendor['name'] ?? ''));?>