From 97f9365c30a39fa8e9f640fd1ae1be84f2c28fb5 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Thu, 5 Sep 2019 15:59:38 +0300 Subject: [PATCH] #390 add category seo information --- .../resources/views/advs/list-item.twig | 2 +- .../src/Http/Controller/advsController.php | 13 ++++++++++++- ...isiosoft.module.cats__create_cats_fields.php | 3 +++ ...soft.module.cats__create_category_stream.php | 4 +++- .../cats-module/resources/lang/en/field.php | 6 ++++++ .../cats-module/resources/lang/tr/field.php | 6 ++++++ .../resources/views/cats/admin-cat.twig | 2 ++ .../cats-module/src/Category/CategoryModel.php | 17 ++++++++++++++++- .../resources/views/partials/metadata.twig | 17 ++++++++++++++--- 9 files changed, 63 insertions(+), 7 deletions(-) diff --git a/addons/default/visiosoft/advs-module/resources/views/advs/list-item.twig b/addons/default/visiosoft/advs-module/resources/views/advs/list-item.twig index fcd9f09b2..867ff70b6 100644 --- a/addons/default/visiosoft/advs-module/resources/views/advs/list-item.twig +++ b/addons/default/visiosoft/advs-module/resources/views/advs/list-item.twig @@ -3,7 +3,7 @@ {% block ogdata %} - + diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php index 740fe5589..dc4c78aa4 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php @@ -66,7 +66,6 @@ class AdvsController extends PublicController { $customParameters = array(); $param = $request->toArray(); - $advmodel = new AdvModel(); $isActiveDopings = $advmodel->is_enabled('dopings'); $isActiveCustomFields = $advmodel->is_enabled('customfields'); @@ -100,6 +99,15 @@ class AdvsController extends PublicController if (isset($param['cat']) and $param['cat'] != "") { $cat = $param['cat']; $mainCats = new CategoryModel(); + + $seo_keywords = $mainCats->getMeta_keywords($param['cat']); + $seo_description = $mainCats->getMeta_description($param['cat']); + $seo_title = $mainCats->getMeta_title($param['cat']); + + $this->template->set('meta_keywords', implode(',', $seo_keywords)); + $this->template->set('meta_description', $seo_description); + $this->template->set('meta_title', $seo_title); + $mainCats = $mainCats->getParentCats($cat, 'category_ids'); $subCats = $categories->getSubCatById($cat); } else { @@ -212,6 +220,9 @@ class AdvsController extends PublicController $qrModel = new QrModel(); $qrSRC = $qrModel->source($adv); } + $this->template->set('meta_keywords', implode(',',explode(' ',$adv->name))); + $this->template->set('meta_description', strip_tags($adv->advs_desc,'')); + $this->template->set('meta_title', $adv->name."|".end($categories)['name']); if ($adv->created_by_id == isset(auth()->user()->id) OR $adv->status == "approved") { diff --git a/addons/default/visiosoft/cats-module/migrations/2019_04_01_160927_visiosoft.module.cats__create_cats_fields.php b/addons/default/visiosoft/cats-module/migrations/2019_04_01_160927_visiosoft.module.cats__create_cats_fields.php index 73d7672a2..6add00a55 100644 --- a/addons/default/visiosoft/cats-module/migrations/2019_04_01_160927_visiosoft.module.cats__create_cats_fields.php +++ b/addons/default/visiosoft/cats-module/migrations/2019_04_01_160927_visiosoft.module.cats__create_cats_fields.php @@ -36,6 +36,9 @@ class VisiosoftModuleCatsCreateCatsFields extends Migration 'mode' => 'upload', ] ], + 'seo_keyword' => 'anomaly.field_type.tags', + 'seo_description' => 'anomaly.field_type.text', + ]; } diff --git a/addons/default/visiosoft/cats-module/migrations/2019_04_01_161009_visiosoft.module.cats__create_category_stream.php b/addons/default/visiosoft/cats-module/migrations/2019_04_01_161009_visiosoft.module.cats__create_category_stream.php index bccd5f885..0a4e3bf57 100644 --- a/addons/default/visiosoft/cats-module/migrations/2019_04_01_161009_visiosoft.module.cats__create_category_stream.php +++ b/addons/default/visiosoft/cats-module/migrations/2019_04_01_161009_visiosoft.module.cats__create_category_stream.php @@ -37,7 +37,9 @@ class VisiosoftModuleCatsCreateCategoryStream extends Migration 'parent_category', 'order', 'deleted_at', - 'files' + 'files', + 'seo_keyword', + 'seo_description', ]; } diff --git a/addons/default/visiosoft/cats-module/resources/lang/en/field.php b/addons/default/visiosoft/cats-module/resources/lang/en/field.php index 0bfdde6ae..384226ae0 100644 --- a/addons/default/visiosoft/cats-module/resources/lang/en/field.php +++ b/addons/default/visiosoft/cats-module/resources/lang/en/field.php @@ -13,5 +13,11 @@ return [ 'files' => [ 'name' => 'Image' ], + 'seo_keyword' => [ + 'name' => 'Seo Keyword' + ], + 'seo_description' => [ + 'name' => 'Seo Description' + ], 'please_wait' => 'Please wait.Deleting Sub Categories', ]; diff --git a/addons/default/visiosoft/cats-module/resources/lang/tr/field.php b/addons/default/visiosoft/cats-module/resources/lang/tr/field.php index bc5c75c89..a83091e8f 100644 --- a/addons/default/visiosoft/cats-module/resources/lang/tr/field.php +++ b/addons/default/visiosoft/cats-module/resources/lang/tr/field.php @@ -17,5 +17,11 @@ "name" =>"görüntü", ], + 'seo_keyword' => [ + 'name' => 'Seo Anahtar Kelimeler' + ], + 'seo_description' => [ + 'name' => 'Seo Açıklaması' + ], "please_wait" =>"Lütfen bekleyin. Alt Kategoriler Siliniyor" ]; \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/resources/views/cats/admin-cat.twig b/addons/default/visiosoft/cats-module/resources/views/cats/admin-cat.twig index e07dbcc6d..c6d911a7f 100644 --- a/addons/default/visiosoft/cats-module/resources/views/cats/admin-cat.twig +++ b/addons/default/visiosoft/cats-module/resources/views/cats/admin-cat.twig @@ -25,6 +25,8 @@ value="{% if form.fields.parent_category.value.id is defined %}{{ form.fields.parent_category.value.id }}{% elseif app.request.get('parent') is defined %}{{ app.request.get('parent') }}{% endif %}"> {{ form.fields.order|raw }} {{ form.fields.files|raw }} + {{ form.fields.seo_keyword|raw }} + {{ form.fields.seo_description|raw }} diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php b/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php index 6e8111044..2906f705d 100644 --- a/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php +++ b/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php @@ -109,6 +109,21 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface public function getMainCategory() { - return $this->where('parent_category_id',NULL)->get(); + return $this->where('parent_category_id', NULL)->get(); + } + + public function getMeta_keywords($cat_id) + { + return $this->find($cat_id)->seo_keyword; + } + + public function getMeta_description($cat_id) + { + return $this->find($cat_id)->seo_description; + } + + public function getMeta_title($cat_id) + { + return $this->find($cat_id)->name; } } diff --git a/addons/default/visiosoft/default-theme/resources/views/partials/metadata.twig b/addons/default/visiosoft/default-theme/resources/views/partials/metadata.twig index 365700dd1..e94c14fd7 100644 --- a/addons/default/visiosoft/default-theme/resources/views/partials/metadata.twig +++ b/addons/default/visiosoft/default-theme/resources/views/partials/metadata.twig @@ -21,11 +21,22 @@ {% else %} - + +{% endif %} + +{{ setting_value('streams::name', config_get('streams::distribution.name')) }}|{{ trans(template.meta_title) }} +{% if app.request.pathInfo == "advs/adv/" %} +{% block opengraph %} + + {##} + + + + +{% endblock %} {% endif %} -{{ setting_value('streams::name', config_get('streams::distribution.name')) }} - |{{ trans(template.meta_title) }} {#{{ favicons("theme::img/favicon.png") }}#}