Post by susanjoy » Fri Apr 20, 2012 5:30 pm

Hello Opencart Community!

After searching and searching, I FINALLY found a solution to putting my list of manufacturers in the top navigation as a dropdown list. It was a free VQmod (code below) and it is wonderful. I would like to however tweak the code a bit, but don't know what to change and I was hoping someone here could help!

I am using Opencart version 1.5.1.3
Default Template (with modifications)


The change I would like to make is:

I would like to only list 10 of my manufacturers in the dropdown list (not the first 10 in the list, but 10 specific brands that are top sellers) and have the last item be a link called "See All..." that leads to the page that shows all Manufacturers in an Alphabetical List (Find Your Favorite Brand)... (I tried using a negative sort order in admin, but that doesn't hide them from the list, nor does a very high number put a link at the end of the list - probably because they are coded to be listed in alphabetical order.)

For now, I put the "See All" link at the end, but I don't understand how the coding works so I don't know what to change in order to make my "See All" link show up right after the last Manufacturer link in the list. Also, please note that I changed the Manufacturer/Brand heading to say "Designers"

The VQmod code that added my manufacturers list to the top navigation is here:

Code: Select all

<modification>
	<id>Manufacturer In Top Menu</id>
	<version>1.5.1.2</version>
	<vqmver>2.0</vqmver>
	<author>jimmy phong</author>
	<file name="catalog/controller/common/header.php">
		<operation>
			<search position="before">
				<![CDATA[if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {]]>
			</search>
			<add>
				<![CDATA[//load manufacturer
			$this->data['text_manufacturer'] = $this->language->get('text_manufacturer');
			$this->data['href_manufacturer'] = $this->url->link('product/manufacturer');
			$data = array();
			$this->load->model('catalog/manufacturer');
			$this->data['manufacturer'] = array();
			$manufacturers = $this->model_catalog_manufacturer->getManufacturers($data);
			if($manufacturers){
				foreach($manufacturers as $manufacturer){
					$this->data['manufacturer'][] = array(
						'name' => $manufacturer['name'],
						'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id='.$manufacturer['manufacturer_id'])
					);
				}}]]>
			</add>
		</operation>
	</file>
	<file name="catalog/view/theme/default/template/common/header.tpl">
		<operation error="skip">
			<search position="after">
				<![CDATA[
					 <li><?php echo( '<a href="http://www.mysite.com/index.php?route=product/latest">WHAT'S NEW</a>' ); ?></li>
				]]>
			</search>
			<add>
				<![CDATA[
				<li>
					<a href="<?php echo $href_manufacturer; ?>"><?php echo $text_manufacturer; ?></a>
					<div>
					  <?php for ($i = 0; $i < count($manufacturer);) { ?>
				        <ul>
				          <?php $j = $i + ceil(count($manufacturer) / 4); ?>
				          <?php for (; $i < $j; $i++) { ?>
							<?php if (isset($manufacturer[$i])) { ?>
								<li><a href="<?php echo $manufacturer[$i]['href']; ?>"><?php echo $manufacturer[$i]['name']; ?></a></li>
							<?php } ?>
				          <?php } ?>
				        </ul>
				        <?php } ?>
						<ul>
						<li><?php echo( '<a href="http://www.mysite.com/index.php?route=product/manufacturer">SEE ALL</a>' ); ?></li>
						</ul>
					</div>
				</li>
				]]>
			</add>
		</operation>
	</file>
	
	<file name="catalog/language/english/common/header.php">
		<operation>
			<search position="after">
				<![CDATA[
					// Text
				]]>
			</search>
			<add>
				<![CDATA[
					$_['text_manufacturer'] = 'Designers';
				]]>
			</add>
		</operation>
	</file>
</modification>
Here is a snapshot of what my top nav bar looks like:

Image

Thank you in advance for your help!
Last edited by susanjoy on Sat Apr 21, 2012 1:36 pm, edited 1 time in total.

Newbie

Posts

Joined
Mon Nov 29, 2010 11:44 am

Post by stevemarsbar » Fri Apr 20, 2012 6:30 pm

Hi,

Do you have a link to the original VqMod?

Thanks

Steve

EDIT: Found it, many thanks :)

http://www.opencart.com/index.php?route ... on_id=3633

Please check out my OpenCart shop which is now trading!
http://www.directmuscle.co.uk


New member

Posts

Joined
Tue Apr 17, 2012 2:02 am

Post by scd1982 » Tue Aug 07, 2012 4:28 am

Is there any way that this would work for OC 1.4.x? I'm interested in putting a list of brands in the header as a dropdown like this, but can't seem to get it to work.
Specifically, when I upload the VQMod above, I get the following error:
Fatal error: Call to a member function link() on a non-object in /home/ogomo/public_html/vqmod/vqcache/vq2-catalog_controller_common_header.php on line 253
Line 253 of the above file is:

Code: Select all

$this->data['href_manufacturer'] = $this->url->link('product/manufacturer');

I usually forget to mention I'm using OC v1.4.9.4


New member

Posts

Joined
Tue Mar 27, 2012 3:57 am

Post by jimmyphong » Tue Aug 07, 2012 5:31 am

so can split 10 manufacuturers with some cusotme code here

Code: Select all

$manufacturers = $this->model_catalog_manufacturer->getManufacturers($data);
         if($manufacturers){
            foreach($manufacturers as $manufacturer){
               $this->data['manufacturer'][] = array(
                  'name' => $manufacturer['name'],
                  'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id='.$manufacturer['manufacturer_id'])
               );
            }
change to

Code: Select all

$manufacturers = $this->model_catalog_manufacturer->getManufacturers($data);
         if($manufacturers){
           array_splice($manufacturers,10); // cut 10 item
            foreach($manufacturers as $manufacturer){
               $this->data['manufacturer'][] = array(
                  'name' => $manufacturer['name'],
                  'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id='.$manufacturer['manufacturer_id']),
                 'sort_order' => $manufacurer['sort_order'] //add sortorder
               );
            }
         //sort with sort order
           $sort_order = array(); 
		foreach ($this->data['manufacturer'] as $key => $value) {
			$sort_order[$key] = $value['sort_order'];
		}
	array_multisort($sort_order, SORT_ASC, $this->data['manufacturer']);
        //add will all to manufacturer
        $this->data['manufacturer'][] = array(
                  'name' => 'SEE ALL',
                  'href' => $this->url->link('product/manufacturer'),
        );

so some fix with sort order versions download in
http://www.opextensions.com/extensions/ ... navigation

News CMS || Plus SEO || Live Price change with Option Select


Active Member

Posts

Joined
Sat Aug 13, 2011 2:48 am

Who is online

Users browsing this forum: No registered users and 19 guests