Forums / Templates, Stylesheets, Page Layout / Custom Sidebar for different product categories

Custom Sidebar for different product categories

Locked

Started by samleeiii on 20 Nov 2008, 11:09 AM · Views: 3,088

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
20 Nov 2008, 11:09 AM
#1
samleeiii avatar

samleeiii

New Zenner

Join Date:
Nov 2008
Posts:
2
Plugin Contributions:
0

Custom Sidebar for different product categories

Hello. I want to create a custom sidebar for different product categories. Doesn't have to be dynamic. I actually want to hard code the sidebars... but I'm wondering how to make it so that when I click on a category, it displays a specific file for the sidebar.

Or perhaps I could create static pages, and then use some code to output products from a specific category?

Any help would be much appreciated! :smile:

26 Mar 2010, 12:35 PM
#2
pakenney avatar

pakenney

New Zenner

Join Date:
Nov 2007
Posts:
5
Plugin Contributions:
0

Re: Custom Sidebar for different product categories

Better late than never...
To match a product category with a specific sidebar image:
I added the Blank Sidebox module (http://www.zen-cart.com/index.php?main_page=product_contrib_info&cPath=40_52&products_id=174) and then modified the script slightly to match a portion of the URL to a specific image; specfically "Path=#", since each product has a unique Path=#.

Here's the modified tpl_blank_sidebox.php code:

<?php if (stripos($_SERVER['REQUEST_URI'],'Path=3') !== false) 
	{$img1 = '<img src="http://www.example.com/images/image1.jpg" alt="" />';} 
		elseif (stripos($_SERVER['REQUEST_URI'],'Path=4') !== false)
			{$img1 = '<img src="http://www.example.com/images/image2.jpg" alt="" />';} 
		else {$img1 = '<img src="http://www.example.com/images/image3.jpg" alt="" />';} 
?>
<?php
/**
 * blank sidebox - allows a blank sidebox to be added to your site
 *
 * @package templateSystem
 * @copyright 2007 Kuroi Web Design
  * @copyright Portions Copyright 2003-2007 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: blank_sidebox.php 2007-05-26 kuroi $
 */

  $content = '';
  $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';

  // Replace the text and HTML tags between the apostophes on lines 19 and 20.
  // Use as many or as few lines using this model as you need for your custom content.
  // If you have a multilingual site define your text in the languages/YOUR_LANGUAGE/extra_definitions/blank_sidebox_defines.php and include it as shown in line 19.
  // If your site is monolingual, you can put the text right here as shown on line 20 (and nobody will know!)
  // $content .= '<p>' . TEXT_LEFT_SIDEBOX . '</p>';
   $content .= $img1;

  $content .= '</div>';
?>

So far this has worked great. Hope it helps someone else looking for a similar solution...

26 Mar 2010, 2:37 PM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Custom Sidebar for different product categories

This is a good general approach that could be used for selecting any number of things in addition to images.
A somewhat simpler way of accomplishing this task would be```php
if ($_GET['cPath'] == '3') {
$img1 = '<img src="http://www.example.com/images/image1.jpg" alt="" />';
} elseif ($_GET['cPath'] == '4') {
$img1 = '<img src="http://www.example.com/images/image2.jpg" alt="" />';
} else {
$img1 = '<img src="http://www.example.com/images/image3.jpg" alt="" />';
}

26 Mar 2010, 9:47 PM
#4
pakenney avatar

pakenney

New Zenner

Join Date:
Nov 2007
Posts:
5
Plugin Contributions:
0

Re: Custom Sidebar for different product categories

Excellent...so simple and yet so elegant! Thanks Glenn!