I have to added One New Custom Module Position above menu in header(Latest OpenCart version 2.3.0.2). and, it is working fine. does all module display in it new header position.
but, Now, the problem is: the javascript codes & stylesheet does not display. if, it module enabled in new header position.
Example: if, I have enabled slideshow module in it new header position. So, Slideshow module is display in new header position but, does not call JS & CSS file.
Please any help/suggestion.
but, Now, the problem is: the javascript codes & stylesheet does not display. if, it module enabled in new header position.
Example: if, I have enabled slideshow module in it new header position. So, Slideshow module is display in new header position but, does not call JS & CSS file.
Please any help/suggestion.
Last edited by keyuri33 on Sat Sep 24, 2016 9:56 pm, edited 1 time in total.
Thanks
it depends on how you're adding the new header position. perhaps you would like to elaborate further on it?
Thanks for reply. I have added following code for new custom position. but, Module call & define fine in it new position. but, does not define js & css form any module(banner, slideshow module etc..).
First I have to add a template and a controller in catalog/view/theme/default/template/common I have use the same code as it is in content_top.php & content_top.tpl, just rename the file as our new position name.
catalog\controller\common\header.php
catalog\view\theme\default\template\common\header.tpl
admin/controller/design/layout.php
admin/language/en-gb/design/layout.php
admin/view/template/design/layout_form.tpl
also, added(define) #module-new-head in bottom of the page "delegate" & "trigger" java script in layout_form.tpl file.
First I have to add a template and a controller in catalog/view/theme/default/template/common I have use the same code as it is in content_top.php & content_top.tpl, just rename the file as our new position name.
catalog\controller\common\header.php
Code: Select all
$data['new_head'] = $this->load->controller('common/new_head');
Code: Select all
<?php echo $new_head; ?>
Code: Select all
$data['text_new_head] = $this->language->get('text_new_head');
Code: Select all
$_['text_hd_ctf'] = 'New Header Position';
Code: Select all
<table id="module-new-head" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<td class="text-center"><?php echo $text_new_head; ?></td>
</tr>
</thead>
<tbody>
<?php foreach ($layout_modules as $layout_module) { ?>
<?php if ($layout_module['position'] == 'new_head') { ?>
<tr id="module-row<?php echo $module_row; ?>">
<td class="text-left"><div class="input-group">
<select name="layout_module[<?php echo $module_row; ?>][code]" class="form-control input-sm">
<?php foreach ($extensions as $extension) { ?>
<optgroup label="<?php echo $extension['name']; ?>">
<?php if (!$extension['module']) { ?>
<?php if ($extension['code'] == $layout_module['code']) { ?>
<option value="<?php echo $extension['code']; ?>" selected="selected"><?php echo $extension['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $extension['code']; ?>"><?php echo $extension['name']; ?></option>
<?php } ?>
<?php } else { ?>
<?php foreach ($extension['module'] as $module) { ?>
<?php if ($module['code'] == $layout_module['code']) { ?>
<option value="<?php echo $module['code']; ?>" selected="selected"><?php echo $module['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $module['code']; ?>"><?php echo $module['name']; ?></option>
<?php } ?>
<?php } ?>
<?php } ?>
</optgroup>
<?php } ?>
</select>
<input type="hidden" name="layout_module[<?php echo $module_row; ?>][position]" value="<?php echo $layout_module['position']; ?>" />
<input type="hidden" name="layout_module[<?php echo $module_row; ?>][sort_order]" value="<?php echo $layout_module['sort_order']; ?>" />
<div class="input-group-btn"><a href="<?php echo $layout_module['edit']; ?>" data-toggle="tooltip" title="<?php echo $button_edit; ?>" target="_blank" class="btn btn-primary btn-sm"><i class="fa fa-pencil"></i></a>
<button type="button" onclick="$('#module-row<?php echo $module_row; ?>').remove();" data-toggle="tooltip" title="<?php echo $button_remove; ?>" class="btn btn-danger btn-sm"><i class="fa fa fa-minus-circle"></i></button>
</div>
</div></td>
</tr>
<?php $module_row++; ?>
<?php } ?>
<?php } ?>
</tbody>
<tfoot>
<tr>
<td class="text-left"><div class="input-group">
<select class="form-control input-sm">
<?php foreach ($extensions as $extension) { ?>
<optgroup label="<?php echo $extension['name']; ?>">
<?php if (!$extension['module']) { ?>
<option value="<?php echo $extension['code']; ?>"><?php echo $extension['name']; ?></option>
<?php } else { ?>
<?php foreach ($extension['module'] as $module) { ?>
<option value="<?php echo $module['code']; ?>"><?php echo $module['name']; ?></option>
<?php } ?>
<?php } ?>
</optgroup>
<?php } ?>
</select>
<div class="input-group-btn">
<button type="button" onclick="addModule('new-head');" data-toggle="tooltip" title="<?php echo $button_module_add; ?>" class="btn btn-primary btn-sm"><i class="fa fa-plus-circle"></i></button>
</div>
</div></td>
</tr>
</tfoot>
</table>
Thanks
It depends where you add (1)
In any case you have to add such:
Depending in the positon you add (1) you have to add your css & js either in the new controller or in the header.php above the line
Code: Select all
$data['new_head'] = $this->load->controller('common/new_head');
Code: Select all
$this->document->addStyle( 'catalog/view/theme/default/stylesheet/YOUR.css' );
$this->document->addScript( 'catalog/view/javascript/YOUR.js' );
Code: Select all
$data['styles'] = $this->document->getStyles();
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
HI
i have same issue but i try your solution but not working,
please help me.
Thanks in advance.
i have same issue but i try your solution but not working,
please help me.
Thanks in advance.
For quick, professional OpenCart support please email scf8127@gmail.com
I know it is old subject but it has not issue. I had similar problem but in Opencart 3. I published fix the problem in this subject: viewtopic.php?f=202&t=207541
my website: Tworzenie sklepu internetowego
Who is online
Users browsing this forum: No registered users and 142 guests