mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Merge pull request #311 from openclassify/dia
#74 Improvements of SEO link structure like Vebze
This commit is contained in:
commit
7f2bb843f8
@ -1,4 +1,16 @@
|
||||
<form action="{{ url_route('visiosoft.module.advs::list') }}" method="get">
|
||||
{% if 'cat' in param|keys %}
|
||||
{% set catId = entries('cats', 'category').find(param['cat']) %}
|
||||
{% set cityId = null %}
|
||||
{% if 'city' in param|keys %}
|
||||
{% set citiesArray = param['city'][0]|split(',') %}
|
||||
{% if count(citiesArray) is same as(1) %}
|
||||
{% set cityId = entries('location', 'cities').find(param['city'][0]) %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<form action="{{ url_route('adv_list_seo', [catId.slug, cityId.slug]) }}" method="get">
|
||||
{% else %}
|
||||
<form action="{{ url_route('visiosoft.module.advs::list') }}" method="get">
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<input type="hidden" name="cat" value="{{ app.request.get('cat') }}">
|
||||
<input type="hidden" name="user" value="{{ app.request.get('user') }}">
|
||||
@ -16,7 +28,8 @@
|
||||
'cities':cities,
|
||||
'districts':districts,
|
||||
'neighborhoods':neighborhoods,
|
||||
'villages':villages
|
||||
'villages':villages,
|
||||
'param':param
|
||||
})|raw }}
|
||||
|
||||
<!-- Date Filter Start -->
|
||||
|
||||
@ -28,9 +28,21 @@ class appendRequestURL
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return $this->url
|
||||
. (Str::contains($this->url, '?') ? '&' : '?')
|
||||
. Arr::query($this->appends(array_merge($this->request, $this->new_parameters)));
|
||||
if (count($this->new_parameters) === 0 && count($this->request) === 0) {
|
||||
return $this->url;
|
||||
} elseif (count($this->request) > 0) {
|
||||
return $this->url
|
||||
. (Str::contains($this->url, '?') ? '&' : '?')
|
||||
. Arr::query($this->appends($this->request));
|
||||
} elseif (count($this->new_parameters) > 0) {
|
||||
return $this->url
|
||||
. (Str::contains($this->url, '?') ? '&' : '?')
|
||||
. Arr::query($this->appends($this->new_parameters));
|
||||
} else {
|
||||
return $this->url
|
||||
. (Str::contains($this->url, '?') ? '&' : '?')
|
||||
. Arr::query($this->appends(array_merge($this->request, $this->new_parameters)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -132,6 +132,10 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
|
||||
],
|
||||
'advs/categories' => 'Visiosoft\AdvsModule\Http\Controller\CategoriesController@index',
|
||||
'advs/c/{cat}' => 'Visiosoft\AdvsModule\Http\Controller\CategoriesController@listByCat',
|
||||
'c/{category?}/{city?}' => [
|
||||
'as' => 'adv_list_seo',
|
||||
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index'
|
||||
],
|
||||
'advs/module_active' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index',
|
||||
'advs/create_adv' => [
|
||||
'as' => "advs::create_adv",
|
||||
|
||||
@ -6,7 +6,8 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CategoriesController extends PublicController {
|
||||
|
||||
public function listByCat($cat) {
|
||||
public function listByCat($cat)
|
||||
{
|
||||
$advs = DB::table('advs_advs')
|
||||
->where('cat1', $cat)
|
||||
->orwhere('cat2', $cat)
|
||||
|
||||
@ -6,11 +6,13 @@ use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
|
||||
use Anomaly\Streams\Platform\Model\Advs\PurchasePurchaseEntryModel;
|
||||
use Anomaly\Streams\Platform\Model\Complaints\ComplaintsComplainTypesEntryModel;
|
||||
use Anomaly\Streams\Platform\Model\Options\OptionsAdvertisementEntryModel;
|
||||
use Visiosoft\AdvsModule\Adv\Command\appendRequestURL;
|
||||
use Visiosoft\AdvsModule\Adv\Event\showAdPhone;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Visiosoft\LocationModule\City\CityRepository;
|
||||
use function PMA\Util\get;
|
||||
use Sunra\PhpSimple\HtmlDomParser;
|
||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||
@ -61,6 +63,7 @@ class AdvsController extends PublicController
|
||||
private $country_repository;
|
||||
|
||||
private $city_model;
|
||||
private $cityRepository;
|
||||
|
||||
private $district_model;
|
||||
|
||||
@ -85,6 +88,7 @@ class AdvsController extends PublicController
|
||||
CountryRepositoryInterface $country_repository,
|
||||
|
||||
CityModel $city_model,
|
||||
CityRepository $cityRepository,
|
||||
|
||||
DistrictModel $district_model,
|
||||
|
||||
@ -111,6 +115,7 @@ class AdvsController extends PublicController
|
||||
$this->country_repository = $country_repository;
|
||||
|
||||
$this->city_model = $city_model;
|
||||
$this->cityRepository = $cityRepository;
|
||||
|
||||
$this->district_model = $district_model;
|
||||
|
||||
@ -138,7 +143,7 @@ class AdvsController extends PublicController
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\View|mixed
|
||||
*/
|
||||
public function index()
|
||||
public function index($category = null, $city = null)
|
||||
{
|
||||
$customParameters = array();
|
||||
$featured_advs = array();
|
||||
@ -146,11 +151,55 @@ class AdvsController extends PublicController
|
||||
|
||||
$param = $this->requestHttp->toArray();
|
||||
|
||||
|
||||
$countries = $this->country_repository->viewAll();
|
||||
|
||||
$isActiveDopings = $this->adv_model->is_enabled('dopings');
|
||||
|
||||
// Search by category slug
|
||||
if ($category) {
|
||||
$categoryId = $this->category_repository->findBy('slug', $category);
|
||||
if ($categoryId) {
|
||||
$param['cat'] = $categoryId->id;
|
||||
}
|
||||
}
|
||||
|
||||
// Search by city slug
|
||||
if (is_null($city) && isset($param['city'][0]) && !empty($param['city'][0]) && strpos($param['city'][0], ',') === false) {
|
||||
$cityId = $this->cityRepository->find($param['city'][0]);
|
||||
return redirect($this->fullLink(
|
||||
$param,
|
||||
route('adv_list_seo', [$categoryId->slug, $cityId->slug]),
|
||||
array()
|
||||
));
|
||||
} elseif (isset($param['city']) && !empty($param['city'][0]) && strpos($param['city'][0], ',') === false) {
|
||||
$cityId = $this->cityRepository->find($param['city'][0]);
|
||||
$param['city'] = [$cityId->id];
|
||||
if ($city !== $cityId->slug) {
|
||||
return redirect($this->fullLink(
|
||||
$param,
|
||||
route('adv_list_seo', [$categoryId->slug, $cityId->slug]),
|
||||
array()
|
||||
));
|
||||
}
|
||||
} elseif ($city && isset($param['city'][0]) && !empty($param['city'][0]) && strpos($param['city'][0], ',') !== false) {
|
||||
return redirect($this->fullLink(
|
||||
$param,
|
||||
route('adv_list_seo', [$categoryId->slug]),
|
||||
array()
|
||||
));
|
||||
} elseif ($city) {
|
||||
if (isset($param['city'][0]) && empty($param['city'][0])) {
|
||||
return redirect($this->fullLink(
|
||||
$param,
|
||||
route('adv_list_seo', [$categoryId->slug]),
|
||||
array()
|
||||
));
|
||||
} 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->addAttributes($advs);
|
||||
@ -218,7 +267,7 @@ class AdvsController extends PublicController
|
||||
|
||||
$viewType = $this->requestHttp->cookie('viewType');
|
||||
|
||||
$compact = compact('advs', 'countries', 'mainCats', 'subCats', 'checkboxes', 'request',
|
||||
$compact = compact('advs', 'countries', 'mainCats', 'subCats', 'checkboxes', 'request', 'param',
|
||||
'user', 'userProfile', 'featured_advs', 'viewType', 'topfields', 'ranges', 'seenList', 'searchedCountry', 'radio');
|
||||
|
||||
if (isset($viewType) and $viewType == 'table')
|
||||
@ -231,6 +280,10 @@ class AdvsController extends PublicController
|
||||
return $this->view->make('visiosoft.module.advs::list/list', $compact);
|
||||
}
|
||||
|
||||
public function fullLink($request, $url, $newParameters) {
|
||||
return $this->dispatch(new appendRequestURL($request, $url, $newParameters));
|
||||
}
|
||||
|
||||
public function viewType($type)
|
||||
{
|
||||
Cookie::queue(Cookie::make('viewType', $type, 84000));
|
||||
|
||||
@ -17,33 +17,39 @@
|
||||
{% set id = maincat['id'] %}
|
||||
{% set parent_category = true %}
|
||||
{% if app.request.get('cat') is null or app.request.get('cat') == "" %}
|
||||
{% set name = maincat.name %}
|
||||
{% set id = maincat.id %}
|
||||
{% set parent_category = false %}
|
||||
{% if params.param['cat'] is null or params.param['cat'] == "" %}
|
||||
{% set name = maincat.name %}
|
||||
{% set id = maincat.id %}
|
||||
{% set parent_category = false %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a href="
|
||||
{% if(viewType != "map") %}
|
||||
{{ appendRequestURL(request_query(),url_route('visiosoft.module.advs::list'),{'cat':id}) }}
|
||||
{% else %}
|
||||
{{ appendRequestURL(request_query(),url_route('advs_map_list'),{'cat':id}) }}
|
||||
{% endif %}
|
||||
"
|
||||
class="list-group-item list-group-item-action text-truncate">
|
||||
{% set catId = entries('cats', 'category').find(id) %}
|
||||
{% set cityId = null %}
|
||||
{% if 'city' in params.param|keys %}
|
||||
{% set citiesArray = params.param['city'][0]|split(',') %}
|
||||
{% if count(citiesArray) is same as(1) %}
|
||||
{% set cityId = entries('location', 'cities').find(params.param['city'][0]) %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a href="{% if(viewType != "map") %}
|
||||
{{ appendRequestURL(request_query(),url_route('adv_list_seo', [catId.slug, cityId.slug]),{}) }}
|
||||
{% else %}
|
||||
{{ appendRequestURL(request_query(),url_route('advs_map_list'),{'cat':id}) }}
|
||||
{% endif %}" class="list-group-item list-group-item-action text-truncate">
|
||||
<i class="fas fa-dot-circle"></i>
|
||||
{{ name }}
|
||||
</a>
|
||||
{% for subcat in params.subCats %}
|
||||
<div class="list-group pl-3 bg-light">
|
||||
{% if subcat.parent_category_id == maincat['id'] %}
|
||||
<a href="
|
||||
{% if(viewType != "map") %}
|
||||
{{ appendRequestURL(request_query(),url_route('visiosoft.module.advs::list'),{'cat':subcat.id}) }}
|
||||
{% else %}
|
||||
{{ appendRequestURL(request_query(),url_route('advs_map_list'),{'cat':subcat.id}) }}
|
||||
{% endif %}
|
||||
"
|
||||
class="list-group-item list-group-item-action
|
||||
text-truncate">{{ subcat.name }}</a>
|
||||
{% set subCatId = entries('cats', 'category').find(subcat.id) %}
|
||||
<a href="{% if(viewType != "map") %}
|
||||
{{ appendRequestURL(request_query(),url_route('adv_list_seo', [subCatId.slug, cityId.slug]),{}) }}
|
||||
{% else %}
|
||||
{{ appendRequestURL(request_query(),url_route('advs_map_list'),{'cat':subcat.id}) }}
|
||||
{% endif %}" class="list-group-item list-group-item-action text-truncate">
|
||||
{{ subcat.name }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<span class="float-left">{{ trans("visiosoft.module.location::field.city.name") }}</span>
|
||||
<i class="fas fa-sort-down float-right"></i>
|
||||
</button>
|
||||
{% set selected_cities = app.request.get('city') %}
|
||||
{% set selected_cities = params.param['city'] %}
|
||||
{% set selected_cities_name = [] %}
|
||||
{% for selected_city in selected_cities[0]|split(',') %}
|
||||
{% set selected_cities_name = selected_cities_name|merge([getCity(selected_city|trim(',')).name]) %}
|
||||
@ -26,7 +26,7 @@
|
||||
<div class="text-muted selected-city">
|
||||
<small>{{ selected_cities_name|join(',') }}</small>
|
||||
</div>
|
||||
<input name="city[]" value="{{ app.request.get('city')|join(',') }}" type="hidden">
|
||||
<input name="city[]" value="{{ params.param['city']|join(',') }}" type="hidden">
|
||||
</div>
|
||||
<div class="col-12 px-0 py-1">
|
||||
<button type="button" class="btn btn-default border border-1 w-100 filter-district-btn" data-toggle="modal"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user