Jump to content

Get my module duplicate with hook


zero22hero

Recommended Posts

Hi, I am newbie here

My problem was with 'blocktopmenu' module: this module is registered with 'displayTop' hook and in 'header.tpl' of my theme, I call this hook like this:

{hook h='displayTop' mod='blocktopmenu'}

It works fine but the generated html is duplicated and I dont know why :(

<ul>
<li><a> Link 1</a></li>
<li><a> Link 2</a></li>
<li><a> Link 3</a></li>
<li><a> Link 1</a></li>
<li><a> Link 2</a></li>
<li><a> Link 3</a></li>
</ul>

Instead of:

<ul>
<li><a> Link 1</a></li>
<li><a> Link 2</a></li>
<li><a> Link 3</a></li>
</ul>

I greatly appreciate your help. Thanks in advance!

---------------------------------------------------------------

Update: to understand clearly about this issue, just follow those steps:

- Install a new prestashop v 1.5.x

- Go to BO, Advanced Parameters -> Performance, change the settings to: Template Cache -> Force Compilation, Cache -> No

- Go to \prestashop\themes\default folder, open the header.tpl file, erase all lines of code and replace by:

{hook h='displayTop' mod='blocktopmenu'}

Now go and check your shop, you will see the menu content repeats twice

Edited by zero22hero (see edit history)
Link to comment
Share on other sites

All you should need to do is to go to Modules->Positions and remove the module from the "Top of Pages". By default the module inserts its content in there and by using the smarty plugin you're displaying it now twice.

  • Like 1
Link to comment
Share on other sites

All you should need to do is to go to Modules->Positions and remove the module from the "Top of Pages". By default the module inserts its content in there and by using the smarty plugin you're displaying it now twice.

Hi Paul C,

Thanks for your reply. I checked and there's only one 'Top horizontal menu' module at that position

Logically, if you try to transplant another 'Top horizontal menu' into that position, it will give an error: "

This module has already been transplanted to this hook

", so I can not display it twice by mistake, right?

Edited by zero22hero (see edit history)
Link to comment
Share on other sites

In 'blocktopmenu.php', I tried to use var_dump on $MENU variable before smarty display the template, it's still correct there

But in 'blocktopmenu.tpl', it's showing differently. I dont know what the problem is...

Also, I tried to assign raw html to $this->_menu variable like this:

$this->_menu = '<li><a href="#">Delivery</a></li>
  <li><a href="#">Legal Notice</a></li>';
$this->smarty->assign('MENU', $this->_menu);

Then, it works fine!!! So, what happened with $this->_menu variable??? :(

Edited by zero22hero (see edit history)
Link to comment
Share on other sites

you've got default prstashop template or maybe you use some external non-default solution?

It's important question, maybe issue is with template code. Let us know

Hi vekia,

Thanks for your reply! I'm developing my own theme base on the default one, means I've changed header.tpl, footer.tpl and other template files.

Please let me know which issue I am dealing to?

Link to comment
Share on other sites

you pasted above something like:

 

<ul>
<li><a> Link 1</a></li>
<li><a> Link 2</a></li>
<li><a> Link 3</a></li>
<li><a> Link 1</a></li>
<li><a> Link 2</a></li>
<li><a> Link 3</a></li>
</ul>

 

it looks like the links are duplicated, so in my opinion this is because:

  1. module configuration (you added those links twice)
  2. tpl modification

 

it's hard to say without an access to the BO / .tpl file, but in my opinion you should try to reinstall module and use it with default settings (and tpl files)

Link to comment
Share on other sites

you pasted above something like:

 

<ul>
<li><a> Link 1</a></li>
<li><a> Link 2</a></li>
<li><a> Link 3</a></li>
<li><a> Link 1</a></li>
<li><a> Link 2</a></li>
<li><a> Link 3</a></li>
</ul>

 

it looks like the links are duplicated, so in my opinion this is because:

  1. module configuration (you added those links twice)
  2. tpl modification

 

it's hard to say without an access to the BO / .tpl file, but in my opinion you should try to reinstall module and use it with default settings (and tpl files)

I checked and the settings should be fine.

Also, I tried to re-install the module but no luck.

Link to comment
Share on other sites

Yes, but you said that you modified the .tpl file of this module. Where you modified this file? In modules/blocktopmenu/ or in themes/modules/blocktopmenu ?

 

if second method, prestashop uses this file to compile the template.

 

Sorry for my questions, but all of this are necessary for understanding the issue

Link to comment
Share on other sites

Yes, but you said that you modified the .tpl file of this module. Where you modified this file? In modules/blocktopmenu/ or in themes/modules/blocktopmenu ?

 

if second method, prestashop uses this file to compile the template.

 

Sorry for my questions, but all of this are necessary for understanding the issue

Modifcations are in modules/blocktopmenu/

I think the problem was with the hook when I tried to modify the default theme

I've just re-install prestashop and change the header.tpl to test, you can try it, please check my attachment

prestashop.zip

Link to comment
Share on other sites

hello

 

Yes I am, i downloaded it and i will test it ASAP

wait for my response

 

hey and what about blocktopmenu? you only attached header.tpl file

Hi vekia,

I've updated the information about this issue in #1 post

And I think I found what the problem is... It happened with my performance settings in BO Template Cache -> Force Compilation, Cache -> No

We can avoid this issue by restoring to default settings after we finish developing project but I just want to figure out what caused the problem?

Link to comment
Share on other sites

Maybe in cache blocktopmenu was with duplicated output for menu content (i know that you tried to something with that) you should try to remove cache files, then recompile the theme - and turn it on again. If the problem will not occur again - the problem was with what i said

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...