Merge pull request #2026 from jitendra-webkul/1.0

Issue #1804 fixed
This commit is contained in:
Jitendra Singh 2020-01-10 16:28:27 +05:30 committed by GitHub
commit 9d1887a9a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 66 deletions

View File

@ -3,9 +3,8 @@
namespace Webkul\CMS\Http\Controllers\Shop;
use Webkul\CMS\Http\Controllers\Controller;
use Webkul\CMS\Repositories\CMSRepository as CMS;
use Webkul\Core\Repositories\ChannelRepository as Channel;
use Webkul\Core\Repositories\LocaleRepository as Locale;
use Webkul\CMS\Repositories\CMSRepository;
use Webkul\Core\Repositories\LocaleRepository;
/**
* PagePresenter controller
@ -13,73 +12,58 @@ use Webkul\Core\Repositories\LocaleRepository as Locale;
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class PagePresenterController extends Controller
class PagePresenterController extends Controller
{
/**
* To hold the request variables from route file
* CMSRepository object
*
* @var Object
*/
protected $_config;
protected $cmsRepository;
/**
* To hold the channel reposotry instance
* LocaleRepository object
*
* @var Object
*/
protected $channel;
protected $localeRepository;
/**
* To hold the locale reposotry instance
* Create a new controller instance.
*
* @param \Webkul\CMS\Repositories\CMSRepository $cmsRepository
* @param \Webkul\Core\Repositories\LocaleRepository $localeRepository
* @return void
*/
protected $locale;
/**
* To hold the CMSRepository instance
*/
protected $cms;
public function __construct(Channel $channel, Locale $locale, CMS $cms)
public function __construct(
CMSRepository $cmsRepository,
LocaleRepository $localeRepository
)
{
/**
* Channel repository instance
*/
$this->channel = $channel;
$this->cmsRepository = $cmsRepository;
/**
* Locale repository instance
*/
$this->locale = $locale;
/**
* CMS repository instance
*/
$this->cms = $cms;
$this->_config = request('_config');
$this->localeRepository = $localeRepository;
}
/**
* To extract the page content and load it in the respective view file\
* To extract the page content and load it in the respective view file
*
* @return view
* @param string $slug
* @return \Illuminate\View\View
*/
public function presenter($slug)
{
$currentChannel = core()->getCurrentChannel();
$currentLocale = app()->getLocale();
$currentLocale = $this->localeRepository->findOneByField('code', app()->getLocale());
$currentLocale = $this->locale->findOneWhere([
'code' => $currentLocale
]);
$page = $this->cmsRepository->findOneWhere([
'url_key' => $slug,
'locale_id' => $currentLocale->id,
'channel_id' => core()->getCurrentChannel()->id
]);
$page = $this->cms->findOneWhere([
'url_key' => $slug,
'locale_id' => $currentLocale->id,
'channel_id' => $currentChannel->id
]);
if ($page) {
return view('shop::cms.page')->with('page', $page);
} else {
if (! $page)
abort(404);
}
return view('shop::cms.page')->with('page', $page);
}
}

View File

@ -4,26 +4,14 @@
{{ $page->page_title }}
@endsection
@section('head')
@isset($page->meta_title)
<meta name="title" content="{{ $page->meta_title }}" />
@endisset
@section('seo')
<meta name="title" content="{{ $page->meta_title }}" />
@isset($page->meta_description)
<meta name="description" content="{{ $page->meta_description }}" />
@endisset
<meta name="description" content="{{ $page->meta_description }}" />
@isset($page->meta_keywords)
<meta name="keywords" content="{{ $page->meta_keywords }}" />
@endisset
<link href="{{ asset('themes/default/assets/css/shop.css') }}" rel="stylesheet" />
<meta name="keywords" content="{{ $page->meta_keywords }}" />
@endsection
@section('content-wrapper')
{!! DbView::make($page)->field('html_content')->render() !!}
@endsection
@push('scripts')
<script src="{{ asset('themes/default/assets/js/shop.js') }}" type="text/javascript"></script>
@endpush