optmized code for cms page option while adding/editing navigation link
This commit is contained in:
@@ -186,7 +186,8 @@ class AdminCustomNavigationLinkSettingController extends ModuleAdminController
|
||||
if (empty($this->errors)
|
||||
&& !$objCMS->active
|
||||
) {
|
||||
$this->warnings[] = $this->l('The selected CMS page is currently disabled. Please enable it first in order to activate this navigation link.');
|
||||
$cmsEditLink = $this->context->link->getAdminLink('AdminCmsContent').'&updatecms&id_cms='.(int) $objCMS->id;
|
||||
$this->warnings[] = $this->l('Please enable linked').' <a href="'.$cmsEditLink.'" target="_blank">'.$this->l('CMS page').'</a> '.$this->l('to enable this navigation link.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,13 +224,7 @@ class AdminCustomNavigationLinkSettingController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
|
||||
Media::addJsDef(
|
||||
array(
|
||||
'categoryWiseCmsPages' => json_encode($categoryWiseCmsPages)
|
||||
)
|
||||
);
|
||||
|
||||
$smartyVars['cmsPages'] = $cmsPages;
|
||||
$smartyVars['categoryWiseCmsPages'] = $categoryWiseCmsPages;
|
||||
$smartyVars['categories'] = $cmsCategories;
|
||||
$this->context->smarty->assign($smartyVars);
|
||||
$this->fields_form = array(
|
||||
@@ -403,7 +398,7 @@ class AdminCustomNavigationLinkSettingController extends ModuleAdminController
|
||||
if (isset($pos[2]) && (int) $pos[2] === $idNavigationLink) {
|
||||
if ($objFeatureBlock = new WkCustomNavigationLink((int) $pos[2])) {
|
||||
if (isset($position)
|
||||
&& $objFeatureBlock->updatePosition($way, $position, $idNavigationLink)
|
||||
&& $objFeatureBlock->updatePosition($way, $position)
|
||||
) {
|
||||
echo 'ok position '.(int) $position.' for custom navigation link '.(int) $pos[1].'\r\n';
|
||||
} else {
|
||||
@@ -422,13 +417,13 @@ class AdminCustomNavigationLinkSettingController extends ModuleAdminController
|
||||
public function processStatus()
|
||||
{
|
||||
if (Validate::isLoadedObject($this->loadObject())
|
||||
&& !$this->object->is_custom_link //Check for CMS related navigation link
|
||||
&& $this->object->id_cms
|
||||
&& Validate::isLoadedObject($objCMS = new CMS($this->object->id_cms))
|
||||
) {
|
||||
$objCMS = new CMS($this->object->id_cms);
|
||||
if (!$objCMS->active
|
||||
&& !$this->object->active
|
||||
) {
|
||||
$this->errors[] = $this->l('Please activate the relate CMS page to activate this link');
|
||||
$this->errors[] = $this->l('Please activate the linked CMS page to enable this navigation link.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,17 +18,29 @@
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
setCategoryWiseCmsPages();
|
||||
displayCategoryWiseCmsPages();
|
||||
$("input[name='is_cms_block_link").on('change', function () {
|
||||
toggleElements(this, "#cms_block_content", "#non_cms_block_content");
|
||||
if (parseInt($(this).val())) {
|
||||
$("#cms_block_content").removeClass('hidden');
|
||||
$("#non_cms_block_content").addClass('hidden');
|
||||
} else {
|
||||
$("#cms_block_content").addClass('hidden');
|
||||
$("#non_cms_block_content").removeClass('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
$("input[name='is_custom_redirect_link").on('change', function () {
|
||||
toggleElements(this, ".custom_redirect_link_div", ".custom_redirect_page_div");
|
||||
if (parseInt($(this).val())) {
|
||||
$(".custom_redirect_link_div").removeClass('hidden');
|
||||
$(".custom_redirect_page_div").addClass('hidden');
|
||||
} else {
|
||||
$(".custom_redirect_link_div").addClass('hidden');
|
||||
$(".custom_redirect_page_div").removeClass('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('change', '#id_cms_category', function(){
|
||||
setCategoryWiseCmsPages();
|
||||
displayCategoryWiseCmsPages();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,37 +52,12 @@ function showNavigationLinkLangField(lang_iso_code, id_lang)
|
||||
$('#navigation_link_name_'+id_lang).show();
|
||||
}
|
||||
|
||||
function toggleElements(element, selectorFirst, selectorSecond)
|
||||
function displayCategoryWiseCmsPages()
|
||||
{
|
||||
if (parseInt($(element).val())) {
|
||||
$(selectorFirst).removeClass('hidden');
|
||||
$(selectorSecond).addClass('hidden');
|
||||
} else {
|
||||
$(selectorFirst).addClass('hidden');
|
||||
$(selectorSecond).removeClass('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function setCategoryWiseCmsPages()
|
||||
{
|
||||
var selectedPage = parseInt($('input[name="id_cms"]:checked').val());
|
||||
var selectedCategory = parseInt($('#id_cms_category').val());
|
||||
var cmsPages = JSON.parse(categoryWiseCmsPages);
|
||||
if (!isNaN(selectedCategory)) {
|
||||
cmsPages = cmsPages[selectedCategory];
|
||||
var html = '';
|
||||
$.each(cmsPages, function(i, v) {
|
||||
html += '<tr>';
|
||||
html += '<td><input type="radio" value="'+v['id_cms']+'" name="id_cms"></td>';
|
||||
html += '<td>'+v['id_cms']+'</td>';
|
||||
html += '<td><label for="groupBox_'+v['id_cms']+'">'+v['meta_title']+'</label></td>'
|
||||
html += '</tr>';
|
||||
});
|
||||
$('table.cms_pages tbody').html(html);
|
||||
}
|
||||
$(document).find('.cms_pages').each(function(){
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
if (!isNaN(selectedPage)) {
|
||||
$('input[name="id_cms"][value="'+selectedPage+'"]').attr('checked', 'checked');
|
||||
}
|
||||
|
||||
}
|
||||
$('#cms_pages_'+selectedCategory).show();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{*Display CMS Pages*}
|
||||
{if isset($cmsPages)}
|
||||
{if isset($categoryWiseCmsPages)}
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3">
|
||||
<span class="label-tooltip" data-toggle="tooltip"
|
||||
@@ -79,32 +79,34 @@
|
||||
{l s='Select CMS Page' mod='blocknavigationmenu'}
|
||||
</span>
|
||||
</label>
|
||||
<div class="col-lg-9">
|
||||
<table class="table table-bordered cms_pages" style="width:40%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="fixed-width-xs">
|
||||
</th>
|
||||
<th class="fixed-width-xs"><span class="title_box">{l s='ID' mod='blocknavigationmenu'}</span></th>
|
||||
<th>
|
||||
<span class="title_box">
|
||||
{l s='CMS Page Name' mod='blocknavigationmenu'}
|
||||
</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $cmsPages as $cmsPage}
|
||||
{foreach $categoryWiseCmsPages as $idCMSCategory => $cmsPages}
|
||||
<div class="col-lg-9">
|
||||
<table class="table table-bordered cms_pages" id="cms_pages_{$idCMSCategory}" style="width:40%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><input type="radio" value="{$cmsPage.id_cms|escape:'htmlall':'UTF-8'}" name="id_cms" {if isset($navigationLinkInfo['id_cms']) && $navigationLinkInfo['id_cms'] == $cmsPage.id_cms}checked="checked"{/if}>
|
||||
</td>
|
||||
<td>{$cmsPage.id_cms|escape:'htmlall':'UTF-8'}</td>
|
||||
<td><label for="groupBox_{$cmsPage.id_cms|escape:'htmlall':'UTF-8'}">{$cmsPage.meta_title}</label></td>
|
||||
<th class="fixed-width-xs">
|
||||
</th>
|
||||
<th class="fixed-width-xs"><span class="title_box">{l s='ID' mod='blocknavigationmenu'}</span></th>
|
||||
<th>
|
||||
<span class="title_box">
|
||||
{l s='CMS Page Name' mod='blocknavigationmenu'}
|
||||
</span>
|
||||
</th>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $cmsPages as $cmsPage}
|
||||
<tr>
|
||||
<td><input type="radio" value="{$cmsPage.id_cms|escape:'htmlall':'UTF-8'}" name="id_cms" {if isset($navigationLinkInfo['id_cms']) && $navigationLinkInfo['id_cms'] == $cmsPage.id_cms}checked="checked"{/if}>
|
||||
</td>
|
||||
<td>{$cmsPage.id_cms|escape:'htmlall':'UTF-8'}</td>
|
||||
<td><label for="groupBox_{$cmsPage.id_cms|escape:'htmlall':'UTF-8'}">{$cmsPage.meta_title}</label></td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user