Jump to content

Adding Manufacturer Block dropdown list to blocktopmenu.tpl


Recommended Posts

Hey everyone,

 

First I am very new to Prestashop (less than a couple of days now). I love what I see so far and this forum has been very valuable in helping me out.

 

I'm trying to add the Manufacturer Block dropdown list to the top menu.

 

I've gotten this far, but the menu is empty.

 

I've added this between the <ul>

 

<select id="manufacturer_list" onchange="autoUrl('manufacturer_list', '');">

<option value="0">{l s='Artist Bios' mod='blockmanufacturer'}</option>

{foreach from=$manufacturers item=manufacturer}

<option value="{$link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)}">{$manufacturer.name|escape:'htmlall':'UTF-8'}</option>

{/foreach}

</select>

.

 

The site I am using to learn all this on is:

http://boojh.x10host.com/ps/index.php

 

You can see the little dropdown list to the right. I don't like how it looks. I'd love to see it look like the All Our Products list, but I'm not sure how to get that going.

 

Thank you in advance for your advice.

Link to comment
Share on other sites

Try this: in blocktopmenu.php replace hookDisplayTop (one line with all manufacturers is added)

public function hookDisplayTop($param)
{
 $this->user_groups =  ($this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP')));
 $this->page_name = Dispatcher::getInstance()->getController();
 if (!$this->isCached('blocktopmenu.tpl', $this->getCacheId()))
 {
  $this->makeMenu();
  $this->smarty->assign('MENU_SEARCH', Configuration::get('MOD_BLOCKTOPMENU_SEARCH'));
  $this->smarty->assign('MENU', $this->_menu);
  $this->smarty->assign('this_path', $this->_path);
 }
 $this->smarty->assign('manufacturers', Manufacturer::getManufacturers());
 $this->context->controller->addJS($this->_path.'js/hoverIntent.js');
 $this->context->controller->addJS($this->_path.'js/superfish-modified.js');
 $this->context->controller->addCSS($this->_path.'css/superfish-modified.css');
 $html = $this->display(__FILE__, 'blocktopmenu.tpl', $this->getCacheId());
 return $html;
}

 

Then change code in blocktopmenu.tpl to

 

{if $MENU != ''}

<!-- Menu -->
<div class="sf-contener clearfix">
 <ul class="sf-menu clearfix">
  {$MENU}
  <li>
   <a href="{$link->getPageLink('manufacturer')|escape:'html'}" title="{l s='Artist Bios' mod='blocktopmenu'}">{l s='Artist Bios' mod='blocktopmenu'}</a>
   <ul>
 {foreach from=$manufacturers item=manufacturer name=manufacturer_list}
 <li>
  <a href="{$link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)|escape:'html'}" title="{l s='Learn more about' mod='blockmanufacturer'} {$manufacturer.name}">{$manufacturer.name|escape:'htmlall':'UTF-8'}</a>
 </li>
 {/foreach}
   </ul>
  </li>
  {if $MENU_SEARCH}
   <li class="sf-search noBack" style="float:right">
 <form id="searchbox" action="{$link->getPageLink('search')}" method="get">
  <p>
   <input type="hidden" name="controller" value="search" />
   <input type="hidden" value="position" name="orderby"/>
   <input type="hidden" value="desc" name="orderway"/>
   <input type="text" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'htmlall':'UTF-8'}{/if}" />
  </p>
 </form>
   </li>
  {/if}
 </ul>
</div>
<div class="sf-right"> </div>
<!--/ Menu -->
{/if}

 

Note that this will be very long list for menu item.

Also check this great tutorial http://nemops.com/alphabetical-prestashop-manufacturers/

Maybe it would be great to combine it to menu but probably that is bit more work.

Link to comment
Share on other sites

Wow super close. I don't get the dropdown list yet. But I'm going to search around some more and see what I can figure out (sometimes I get lucky). If you can think of something I might be missing, I'd certainly appreciate it. And thank you again for such a quick reply.

Link to comment
Share on other sites

you can use also something like this:

(no core modifications)

{foreach from=Manufacturers::getMaufacturers() item=manufacturer name=manufacturer_list}
	 <li>
	  <a href="{$link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)|escape:'html'}" title="{l s='Learn more about' mod='blockmanufacturer'} {$manufacturer.name}">{$manufacturer.name|escape:'htmlall':'UTF-8'}</a>
	 </li>
	 {/foreach}

 

don't forget to run "force compilation" and turn off cache while you're working on your template

Link to comment
Share on other sites

Thank you both for your help. So as not to make changes to the core files as recommended in this forum, I've done the following...

A) I created a new theme using the default theme files.

B) In mytheme/modules/ I created a folder called blocktopmenu and placed the modified blocktopmenu.php and blocktopmenu.tpl files in there

C) I turned off cache and ran force compilation

D) I also did the theme modifications as recomended in http://nemops.com/alphabetical-prestashop-manufacturers/

 

Vekia...I tried your suggestion, but it seemed to make my entire site look like a sitemap. (I'm sure I did something wrong there)

 

Razaro...Your suggestion get's me as close as I think may be possible although I get no dropdown the way I do in All Our Products, It does take me to the manufacturers list.

 

I'll keep trying to make that a dropdown link, only because I know that that is how the person I am doing this for wants it.

 

The nemops tutorial was fantastic and does clean up the list very nicely. I have a question to him on how I can make all the manufacturer's name linked even if they have no products.

 

The test site I am using to get all my ducks in a row is http://boojh.x10host.com/ps/index.php

 

My thanks again to both of you and to the others who's posts I have also used in my quest to get this site up and running. Keep up the good work in this forum. I really did find many useful tips.

Link to comment
Share on other sites

  • 5 weeks later...
×
×
  • Create New...