Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Community Contributed Add-Ons / Addon Sideboxes / How to disable "shuffling" of manufacturer logos in the sidebox

How to disable "shuffling" of manufacturer logos in the sidebox

Locked
This thread is locked. New replies are disabled.
23 Aug 2010, 5:30 AM
#1
shirster avatar

shirster

Zen Follower

Join Date:
Sep 2005
Location:
Hong Kong
Posts:
301
Plugin Contributions:
0

Post #1 by shirster

Hello everyone,

I installed the "Sidebox for list Manufacturers logos" addon on one of my 1.3.8a stores. Besides some typos and wrong instruction in the readme file everything works fine. The only problem is that the logos appear in a random order. I would like them to display by alphabetic order instead. Since it's only a few lines of codes I'm hoping it would be an easy task? :)

Thank you in advance ! :)

Link to the addon : http://www.zen-cart.com/index.php?main_page=product_contrib_info&cPath=40_52&products_id=941

<?php
/**
 * Side Box Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: modification of tpl_manufacturers_select.php 4771 2006-10-17 05:32:42Z ajeh $
 * @modify by Alejandro Hurtado <ahurt2000######################>
 */
  if (!defined(BOX_HEADING_MANUFACTURERS_IMG)) define(BOX_HEADING_MANUFACTURERS_IMG,'Manufacturers'); // define sidebox header
  if (!defined(BOX_MANUFACTURER_HOMEPAGE_IMG)) define(BOX_MANUFACTURER_HOMEPAGE_IMG,'web');			 // define link to manufacturers URL 
  
  $title = '<label>' . BOX_HEADING_MANUFACTURERS_IMG . '</label>';
  $title_link = false;
  $content = "";
  $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent centeredContent">';
  while (!$manufacturer_sidebox_img -> EOF){
    $content.='<div >';
	$content.='<a href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturer_sidebox_img->fields['manufacturers_id']) . '">';		
	$content.=zen_image(DIR_WS_IMAGES . $manufacturer_sidebox_img->fields['manufacturers_image'], $manufacturer_sidebox_img->fields['manufacturers_name']);
	$content.= '</a></div>';
	if (zen_not_null($manufacturer_sidebox_img->fields['manufacturers_url']))
		$content.='<a href="' . zen_href_link(FILENAME_REDIRECT, 'action=manufacturer&manufacturers_id=' . $manufacturer_sidebox_img->fields['manufacturers_id']) . '" target="_blank">' . sprintf(BOX_MANUFACTURER_HOMEPAGE_IMG, $manufacturer_sidebox_img->fields['manufacturers_name']) . '</a>';
	
	$manufacturer_sidebox_img->MoveNext();
  }
  $content .= '</div>';
?>
23 Aug 2010, 8:52 AM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Post #2 by kuroi

The module is operating as it was designed to do, i.e. extract a limited number of random logos for display.

However, this is open source, so if that doesn't fit the needs of your site, that's absolutely fine. It can be changed.

To alphabetise all the logos by manufacturer's name instead, you need to change the includes/modules/sideboxes/YOUR_TEMPLATE/manufacturers_img.php file.

Simply change line 39 from

ORDER BY RAND() LIMIT 0,". BOX_MANUFACTURER_MAX_LOGOS ;
```to
```php
ORDER BY m.manufacturers_name;
```(untested but should work)

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

23 Aug 2010, 9:02 AM
#3
shirster avatar

shirster

Zen Follower

Join Date:
Sep 2005
Location:
Hong Kong
Posts:
301
Plugin Contributions:
0

Post #3 by shirster

Thanks for your response, yes I realized that the logos were randomized by design, but I would like to display them all in alphabetic order :)

Thank you for your help on the code, this is what I did to get it to work :

Change from :

ORDER BY RAND() LIMIT 0,". BOX_MANUFACTURER_MAX_LOGOS ;

To :

ORDER BY m.manufacturers_name LIMIT 0,". BOX_MANUFACTURER_MAX_LOGOS ;

Thanks again ! :)