@@ -36,7 +35,9 @@
'districts':districts,
'neighborhoods':neighborhoods,
'villages':villages,
- 'param':param
+ 'param':param,
+ 'categoryId':categoryId,
+ 'cityId':cityId
})|raw }}
diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
index 50f7aac4c..5d50576d3 100644
--- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
+++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
@@ -46,7 +46,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
return $this->model->orderBy('created_at', 'DESC')->where('advs_advs.id', $id)->first();
}
- public function searchAdvs($type, $param = null, $customParameters = null, $limit = null)
+ public function searchAdvs($type, $param = null, $customParameters = null, $limit = null, $category = null, $city = null)
{
$isActiveDopings = new AdvModel();
$isActiveDopings = $isActiveDopings->is_enabled('dopings');
@@ -78,20 +78,21 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
if (!empty($param['country'])) {
$query = $query->where('country_id', $param['country']);
}
- if (isset($param['city']) and !empty($param['city']) and !empty(array_filter($param['city']))) {
+ if ($city) {
+ $query = $query->where('city', $city->id);
+ } elseif (isset($param['city']) and !empty($param['city']) and !empty(array_filter($param['city']))) {
$query = $query->whereIn('city', $param['city']);
}
- if (!empty($param['cat'])) {
+ if ($category) {
$cat = new CategoryModel();
- $cat_d = $cat->find($param['cat']);
- if ($cat_d) {
- if ($cat_d->parent_category_id == null) {
+ if ($category) {
+ if ($category->parent_category_id == null) {
$catLevel = 1;
} else {
- $catLevel = $cat->getCatLevel($param['cat']);
+ $catLevel = $cat->getCatLevel($category->id);
}
$catLevel = "cat" . $catLevel;
- $query = $query->where($catLevel, $param['cat']);
+ $query = $query->where($catLevel, $category->id);
}
}
if (!empty($param['user'])) {
diff --git a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php
index a3b32d0ad..5b4309af8 100644
--- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php
+++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php
@@ -6,7 +6,7 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
{
public function findById($id);
- public function searchAdvs($type, $param = null, $customParameters = null, $limit = null);
+ public function searchAdvs($type, $param = null, $customParameters = null, $limit = null, $category = null, $city = null);
public function softDeleteAdv($id);
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 4a4d018fe..59f07811a 100644
--- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php
+++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php
@@ -151,29 +151,41 @@ class AdvsController extends PublicController
$isActiveDopings = $this->adv_model->is_enabled('dopings');
// Search by category slug
+ $categoryId = null;
if ($category) {
$categoryId = $this->category_repository->findBy('slug', $category);
- if ($categoryId) {
- $param['cat'] = $categoryId->id;
+ if (!$categoryId) {
+ $this->messages->error(trans('visiosoft.module.advs::message.category_not_exist'));
+ return redirect('/');
}
- } elseif (isset($param['cat']) && !empty($param['cat'])) {
- $categoryId = $this->category_repository->find($param['cat']);
- if ($categoryId) {
+ if (isset($param['cat'])) {
+ unset($param['cat']);
return redirect($this->fullLink(
$param,
route('adv_list_seo', [$categoryId->slug]),
array()
));
- } else {
+ }
+ } elseif (isset($param['cat']) && !empty($param['cat'])) {
+ $categoryId = $this->category_repository->find($param['cat']);
+ if (!$categoryId) {
$this->messages->error(trans('visiosoft.module.advs::message.category_not_exist'));
return redirect('/');
}
+ unset($param['cat']);
+ return redirect($this->fullLink(
+ $param,
+ route('adv_list_seo', [$categoryId->slug]),
+ array()
+ ));
}
// Search by city slug
+ $cityId = null;
if ($category) {
if (is_null($city) && isset($param['city'][0]) && !empty($param['city'][0]) && strpos($param['city'][0], ',') === false) {
$cityId = $this->cityRepository->find($param['city'][0]);
+ unset($param['city']);
return redirect($this->fullLink(
$param,
route('adv_list_seo', [$categoryId->slug, $cityId->slug]),
@@ -182,6 +194,7 @@ class AdvsController extends PublicController
} elseif (isset($param['city']) && !empty($param['city'][0]) && strpos($param['city'][0], ',') === false) {
$cityId = $this->cityRepository->find($param['city'][0]);
if ($city !== $cityId->slug) {
+ unset($param['city']);
return redirect($this->fullLink(
$param,
route('adv_list_seo', [$categoryId->slug, $cityId->slug]),
@@ -196,6 +209,7 @@ class AdvsController extends PublicController
));
} elseif ($city) {
if (isset($param['city'][0]) && empty($param['city'][0])) {
+ unset($param['city']);
return redirect($this->fullLink(
$param,
route('adv_list_seo', [$categoryId->slug]),
@@ -203,14 +217,13 @@ class AdvsController extends PublicController
));
} else {
$cityId = $this->cityRepository->findBy('slug', $city);
- $param['city'] = [$cityId->id];
}
}
}
$isActiveCustomFields = $this->adv_model->is_enabled('customfields');
- $advs = $this->adv_repository->searchAdvs('list', $param, $customParameters);
+ $advs = $this->adv_repository->searchAdvs('list', $param, $customParameters, null, $categoryId, $cityId);
$advs = $this->adv_repository->addAttributes($advs);
@@ -231,25 +244,23 @@ class AdvsController extends PublicController
}
- if (isset($param['cat']) and $param['cat'] != "") {
- $cat = $param['cat'];
- $seo_keywords = $this->category_model->getMeta_keywords($param['cat']);
- $seo_description = $this->category_model->getMeta_description($param['cat']);
- $seo_title = $this->category_model->getMeta_title($param['cat']);
+ if ($categoryId) {
+ $seo_keywords = $this->category_model->getMeta_keywords($categoryId->id);
+ $seo_description = $this->category_model->getMeta_description($categoryId->id);
+ $seo_title = $this->category_model->getMeta_title($categoryId->id);
$this->template->set('meta_keywords', implode(',', $seo_keywords));
$this->template->set('meta_description', $seo_description);
$this->template->set('meta_title', $seo_title);
- $mainCats = $this->category_model->getMains($cat);
- $current_cat = $this->category_model->getCat($cat);
+ $mainCats = $this->category_model->getMains($categoryId->id);
+ $current_cat = $this->category_model->getCat($categoryId->id);
$mainCats[] = [
'id' => $current_cat->id,
'val' => $current_cat->name,
];
- $subCats = $this->category_repository->getSubCatById($cat);
+ $subCats = $this->category_repository->getSubCatById($categoryId->id);
} else {
- $cat = null;
$mainCats = $this->category_repository->mainCats();
}
@@ -270,7 +281,8 @@ class AdvsController extends PublicController
$viewType = $this->requestHttp->cookie('viewType');
$compact = compact('advs', 'countries', 'mainCats', 'subCats', 'checkboxes', 'request', 'param',
- 'user', 'featured_advs', 'viewType', 'topfields', 'ranges', 'seenList', 'searchedCountry', 'radio');
+ 'user', 'featured_advs', 'viewType', 'topfields', 'ranges', 'seenList', 'searchedCountry', 'radio',
+ 'categoryId', 'cityId');
return $this->viewTypeBasedRedirect($viewType, $compact);
}
diff --git a/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/breadcrumb.twig b/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/breadcrumb.twig
index 2f40e67f9..99ade293e 100644
--- a/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/breadcrumb.twig
+++ b/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/breadcrumb.twig
@@ -1,4 +1,9 @@
-{% if app.request.get('cat') %}
+{% set catSlug = null %}
+{% set pathInfo = app.request.pathinfo|split('/') %}
+{% if pathInfo[1] == 'c' %}
+ {% set catSlug = pathInfo[2] %}
+{% endif %}
+{% if catSlug %}
{% for category_breadcrumbs in params.mainCats %}