Jump to content

Manufacturers Logo in Top Menu


Recommended Posts

Hi experts

 

I tried to display manufacturers logo instead of their names on Top Menu Manufacturers submenu.

 

I checked this related topic  ( https://www.prestashop.com/forums/topic/368828-manufacturer-list-in-top-menu/ )

but i don't know why that topic is locked already.

 

and as dear Nemo1 said there :

 

About line 490 of blocktopmenu.php. Instead of grabbing the text like this

 

Tools::safeOutput($manufacturer['name'])

 

Use an img tag and point it to

 

_PS_IMG_DIR_ . 'm/'.$manufacturer['id_manufacturer'].'.jpg'

 

I found that line on line 515 in my ps 1.6.14 >>

$this->_menu .= '<li><a href="'.$link->getManufacturerLink((int)$manufacturer['id_manufacturer'], $manufacturer['link_rewrite']).'" title="'.Tools::safeOutput($manufacturer['name']).'">'.Tools::safeOutput($manufacturer['name']).'</a></li>'.PHP_EOL;

 

and i changed this part :

 

'.Tools::safeOutput($manufacturer['name']).'

 

with this one :

 

'.Tools::safeOutput($manufacturer['img']).'

 

but after that i have nothing instead of manufacturer names and manufacturers sub menu is completely empty . 

 

I think i did something as the wrong way , would someone give me some more detailed information about that ?

 

Thanks in advance.

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

I'm trying to do the same thing (sorry I just now noticed this thread, I opened a new one similar to this one yesterday XD)!!!

 

My problem is that if I modify the page I have no visual feedback of the modifications in front-end, it's as if it loads a cache file even if I deleted it.

 

Mhh…..

Link to comment
Share on other sites

This should work _PS_IMG_DIR_ . 'm/'.$manufacturer['id_manufacturer'].'.jpg'

But this will not

 

'.Tools::safeOutput($manufacturer['img']).'

 

Did you try using the former, instead of ['img']?

Hi dear Nemo

Finally you came :-D

 

I'm not much familiar with PHP and when i use your code i receive Blank Screen .

I used your code in this way :

<img src="_PS_IMG_DIR_ . 'm/'.$manufacturer['id_manufacturer'].'.jpg'">

i added >> ( ' . ) to the beginning of your code so blank screen gone

<img src="' . _PS_IMG_DIR_ . 'm/'.$manufacturer['id_manufacturer'].'.jpg'">

 but question marks appeared ! ( it seems the produced manufacturers address is incomplete )

 

_____ Finally

 

 

but finally after some search i found this code on stackoverflow that it worked for me :

<img src="' . __PS_BASE_URI__ . 'img/m/' . (int) $manufacturer['id_manufacturer'] . '.jpg">

and i added a little to it for display specific size of manufacturer images :

<img src="' . __PS_BASE_URI__ . 'img/m/' . (int) $manufacturer['id_manufacturer'] .'-'.'medium_default'. '.jpg">

now it display manufacturers images with medium size .

 

Thank you Nemo, by the way your code inspire me for finding the solution .

Please do correct the code its still not good way or standard way .

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

I'm trying to do the same thing (sorry I just now noticed this thread, I opened a new one similar to this one yesterday XD)!!!

 

My problem is that if I modify the page I have no visual feedback of the modifications in front-end, it's as if it loads a cache file even if I deleted it.

 

Mhh…..

 

kitfoxster

 

I think if you do what i did and explained in my last post , you can make it works . remember after editing the blocktopmenu.php , first go to your backoffice >> advanced parameters >> performance and click clear the cache from top of the page . then refresh your site and check the changes .

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

Hi the_raven!

 

Thanks for the tip, but unfortunately it doesn't work for me. Or at least not yet ehehehe

 

The fact is that I can't even be sure the system is updating the menu's code because even if I empty prestashop's cache (and the browser's) it's not refreshing the menu. I noticed this just by adding a class on the <li> tag, so if a class isn't added I believe your code definetely will not be considered.

 

In any case, I'll attach two image files:

one is to see if I used your code correctly,

http://www.servustuo.com/1.png

 

the other to show you that even if there is an <img> tag in the code, the site continues showing the text version!

http://www.servustuo.com/2.png

 

Headache!

 

I even tried reinstalling the module but no luck: if I modify the .tpl file changes are seen immediately, If I change the .php file nothing happens! Yay! :D

Link to comment
Share on other sites

Ok, the_raven!
 
I can finally confirm that your code works.
 
My problem was that I was working on an override file located in the theme directory, and I just found out that you CANNOT override the module php files in prestashop 1.6. This is pretty unfriendly, I'd say, and for this reason I wasted around 16 working hours, stressed fellow coders, and learned something new.
 
Sometimes it's the simplest thing possible, and you don't notice it. Better laugh and not cry! lol
 
Therefore, modifying the ORGINAL PHP FILE in the ORIGINAL MODULES DIRECTORY, your code works a charm.
 
So, recap:
in Prestashop 1.6 search this code in the /modules/blocktopmenu/blocktopmenu.php file:
 

$this->_menu .= '<li><a href="'.$link->getManufacturerLink((int)$manufacturer['id_manufacturer'], $manufacturer['link_rewrite']).'" title="'.Tools::safeOutput($manufacturer['name']).'">'.Tools::safeOutput($manufacturer['name']).'</a></li>'.PHP_EOL;

 
and change it as the_raven kindly suggested as so:

$this->_menu .= '<li><a href="'.$link->getManufacturerLink((int)$manufacturer['id_manufacturer'], $manufacturer['link_rewrite']).'" title="'.Tools::safeOutput($manufacturer['name']).'"><img src="' . __PS_BASE_URI__ . 'img/m/' . (int) $manufacturer['id_manufacturer'] . '.jpg"></a></li>'.PHP_EOL;

 
No overrides, you have to modify the original module. And if you update it, you'll lose your modifications! :D
Thanks for the patience, finally I can continue with my site!

Link to comment
Share on other sites

I wrote a long text for you :D but before i send it my phone notified me about your post .

 

as i know  if you want to use override you need to use override folder ( front controller )  in main PS folder not in theme folder !

 

but im happy that the code worked for you . 

 

Good Luck

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

You are welcome.

I didn't talk about override possibilities but I know the override action must be done in PS override folder.maybe modules override is different but there is no way to override using theme folder at all. I think if you do a google search about prestashop override you will find your answer very soon because override is one of the most discussed topics about prestashop

Link to comment
Share on other sites

In fact that's what I'll do :D

 

Actually there is an override possibility in the theme folder, I'm currently using it for my site, but it works only with .tpl files (as I just discovered that .php files in this override directory don't work).

 

As of the main override directory, I'll definitely read about its possibilities, structure and whatnot so I can then look at my site and say "BOOYA!!" :D

 

PS: the .tpl override directory structure for modules, in theme folder, work like this:

 

 

/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl

 

and, now that I think of it, also language files can be overridden in theme folder with this structure:

 

/themes/default-bootstrap/modules/blocktopmenu/translations/en.php

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

  • 3 years later...

Hi Guys, i tried this solution and work perfectly for me.

But i have a problem:

I added an img for manufacturers, but now they are so lot, and when I open the tab BRANDS on my top menù Horizontal I don't see all the manufacturers, because menù don't scroll down!!!

Please Help me.

my website: http://romanouomo.com/

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...