Post by keyuri33 » Sat Sep 24, 2016 6:30 pm

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.
Last edited by keyuri33 on Sat Sep 24, 2016 9:56 pm, edited 1 time in total.

Thanks


Newbie

Posts

Joined
Tue Aug 09, 2016 3:50 pm

Post by MarketInSG » Sat Sep 24, 2016 7:47 pm

it depends on how you're adding the new header position. perhaps you would like to elaborate further on it?


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by keyuri33 » Sat Sep 24, 2016 8:59 pm

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

Code: Select all

$data['new_head'] = $this->load->controller('common/new_head');
catalog\view\theme\default\template\common\header.tpl

Code: Select all

<?php echo $new_head; ?>
admin/controller/design/layout.php

Code: Select all

$data['text_new_head] = $this->language->get('text_new_head');
admin/language/en-gb/design/layout.php

Code: Select all

$_['text_hd_ctf'] = 'New Header Position';
admin/view/template/design/layout_form.tpl

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>
also, added(define) #module-new-head in bottom of the page "delegate" & "trigger" java script in layout_form.tpl file.

Thanks


Newbie

Posts

Joined
Tue Aug 09, 2016 3:50 pm

Post by OSWorX » Sat Sep 24, 2016 9:24 pm

It depends where you add (1)

Code: Select all

$data['new_head'] = $this->load->controller('common/new_head');
In any case you have to add such:

Code: Select all

$this->document->addStyle( 'catalog/view/theme/default/stylesheet/YOUR.css' );
$this->document->addScript( 'catalog/view/javascript/YOUR.js' );
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['styles'] = $this->document->getStyles();

Forum Rules: viewtopic.php?f=176&t=200480
Commercial Request: viewforum.php?f=88

Image


User avatar
Expert Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by keyuri33 » Sat Sep 24, 2016 9:47 pm

You are right. It is working fine now.
Thank you.

Thanks


Newbie

Posts

Joined
Tue Aug 09, 2016 3:50 pm

Post by shahid21290 » Thu Feb 16, 2017 3:26 pm

HI

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


User avatar
New member

Posts

Joined
Fri May 03, 2013 8:32 pm

Post by DesignCart » Fri Oct 12, 2018 12:27 am

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 Opencart


User avatar
New member

Posts

Joined
Thu Nov 10, 2016 2:06 pm
Location - Gubin
Who is online

Users browsing this forum: No registered users and 12 guests