Skip to content

armgit / Vvveb

Public Imported from GitHub
0

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

Vendors list component

givanza1880e1e337d
diff --git a/app/component/product/vendors.php b/app/component/product/vendors.php
new file mode 100644
index 0000000..08be212
--- /dev/null
+++ b/app/component/product/vendors.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Component\Product;
+
+use Vvveb\System\Component\ComponentBase;
+use Vvveb\System\Event;
+use function Vvveb\url;
+
+class Vendors extends ComponentBase {
+ public static $defaultOptions = [
+ 'start' => 0,
+ //'language_id' => 1,
+ 'count' => ['url', 4],
+ 'id_vendor' => NULL,
+ 'order' => ['url', 'price asc'],
+ 'id_category' => NULL,
+ 'limit' => 7,
+ 'page' => 1,
+ 'type' => 'tags',
+ 'parents_only' => false,
+ 'parents_children_only' => false,
+ 'parents_without_children' => false,
+ ];
+
+ function results() {
+ $category = new \Vvveb\Sql\VendorSQL();
+ $results = $category->getAll($this->options);
+
+ foreach ($results['vendor'] as &$vendor) {
+ $vendor['url'] = url('product/vendor/index', $vendor);
+ }
+
+ list($results) = Event :: trigger(__CLASS__,__FUNCTION__, $results);
+
+ return $results;
+ }
+}
diff --git a/app/template/components.tpl b/app/template/components.tpl
index 19dcba2..8159d4b 100755
--- a/app/template/components.tpl
+++ b/app/template/components.tpl
@@ -19,6 +19,7 @@ import(components/breadcrumb.tpl, [data-v-component-breadcrumb])
import(components/content/categories.tpl, [data-v-component-content-categories])
import(components/product/categories.tpl, [data-v-component-product-categories])
import(components/product/manufacturers.tpl, [data-v-component-product-manufacturers])
+import(components/product/vendors.tpl, [data-v-component-product-vendors])
import(components/product/subscriptions.tpl, [data-v-component-product-subscriptions])
import(components/product/attributes.tpl, [data-v-component-product-attributes])
import(components/product/options.tpl, [data-v-component-product-options])
diff --git a/app/template/components/product/vendors.tpl b/app/template/components/product/vendors.tpl
new file mode 100644
index 0000000..c0a96ef
--- /dev/null
+++ b/app/template/components/product/vendors.tpl
@@ -0,0 +1,38 @@
+@vendors = [data-v-component-product-vendors]
+@vendor = [data-v-component-product-vendors] [data-v-vendor]
+
+@vendor|deleteAllButFirstChild
+
+@vendors|prepend = <?php
+if (isset($_vendors_idx)) $_vendors_idx++; else $_vendors_idx = 0;
+$previous_component = isset($current_component)?$current_component:null;
+$vendors = $current_component = $this->_component['product_vendors'][$_vendors_idx] ?? [];
+
+$_pagination_count = $vendors['count'] ?? 0;
+$_pagination_limit = isset($vendors['limit']) ? $vendors['limit'] : 5;
+?>
+
+
+@vendor|before = <?php
+$_default = (isset($vvveb_is_page_edit) && $vvveb_is_page_edit ) ? [0 => []] : false;
+$vendors['vendor'] = empty($vendors['vendor']) ? $_default : $vendors['vendor'];
+
+if($vendors && is_array($vendors['vendor'])) {
+ foreach ($vendors['vendor'] as $index => $vendor) {?>
+
+ @vendor|data-vendor_id = $vendor['vendor_id']
+
+ @vendor|id = <?php echo 'vendor-' . $vendor['vendor_id'];?>
+
+ @vendor [data-v-vendor-content] = <?php echo $vendor['content'];?>
+
+ @vendor img[data-v-vendor-*]|src = $vendor['@@__data-v-vendor-(*)__@@']
+
+ @vendor [data-v-vendor-*]|innerText = $vendor['@@__data-v-vendor-(*)__@@']
+
+ @vendor a[data-v-vendor-*]|href = $vendor['@@__data-v-vendor-(*)__@@']
+
+ @vendor|after = <?php
+ }
+}
+?>