Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2008
    Posts
    2
    Plugin Contributions
    0

    Default 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!

  2. #2
    Join Date
    Nov 2007
    Posts
    5
    Plugin Contributions
    0

    Default 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?ma...roducts_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 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...

  3. #3
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    20,981
    Plugin Contributions
    25

    Default 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 Code:
    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="" />';


  4. #4
    Join Date
    Nov 2007
    Posts
    5
    Plugin Contributions
    0

    Default Re: Custom Sidebar for different product categories

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

 

 

Similar Threads

  1. Is there a way to link my blog in my categories sidebar?
    By angelanger in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 5 Sep 2008, 03:54 AM
  2. How to Add Categories to sidebar?
    By vitaman in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 28 Jan 2008, 04:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •