CRE Loaded Community

Banner


Board index » Web Design and Development » Development Discussions

All times are UTC - 5 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: How can I add an image to each category in the left column?
PostPosted: Tue Jun 22, 2010 3:31 am 
Offline
CRE Newbie

Joined: Fri Apr 23, 2010 10:36 am
Posts: 22
I want to have multiple images in the left categories column rather than the arrow image on every category. I found the line in the php but I'm new to code in general so I have no idea how to go about it.

I have searched the forums and I'm sure its pretty simple but I cant find any info.

Cheers,

Sam


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Wed Jul 21, 2010 8:02 am 
Offline
CRE Newbie

Joined: Fri Apr 23, 2010 10:36 am
Posts: 22
Code:
td.Left_category{
    background-image: url("../images/category_arrow.jpg");
    background-repeat:  no-repeat;
    background-position: top left;
    height: 30px;
    padding-top: 0;
    padding-bottom: 3px;
    padding-left: 25px;
    font-size: 11px;
    color: #5E5E5E;


I figure this is the place to change it... can anyone help?

I need to have a sequence of images rather than the same one repeated over and over. I tried a few things but no luck so far.


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Wed Jul 21, 2010 11:52 am 
Offline
CRE Talented

Joined: Sun Nov 29, 2009 10:57 am
Posts: 348
I dont think you will be able to do this via css, you will need custom coding in your categories infobox/class.

http://mdjl-demo.co.uk/demo/featured_products.php

Is this what you are looking for? I haven't converted the sub cateories though.

_________________
CSS Store - http://mdjl40.mdjl-demo.co.uk -Work in Progress
YMM Filter Lists - http://mdjl-demo.co.uk/6-4-1a -Pagnation/Filter Lists


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Thu Jul 22, 2010 3:42 am 
Offline
CRE Newbie

Joined: Fri Apr 23, 2010 10:36 am
Posts: 22
Hi TheLango,

Yep that is exactly what I would like to do. Individual image for each category, I'm not concearned about the subcategories.

I would sure appreciate it if you could help me out with getting this to work.


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Thu Jul 22, 2010 6:30 am 
Offline
CRE Talented

Joined: Sun Nov 29, 2009 10:57 am
Posts: 348
Replace the following file with the code below...

includes/classes/box_categories.php...
Code:
<?php
/*
  $Id: box_categories.php $

  CRE Loaded, Open Source E-Commerce Solutions
  http://www.creloaded.com

  Released under the GNU General Public License
 
  Proivdes the logic to populate the info box by the same name
*/
class box_categories {
  public $row_count = 0;
  public $categories_string = '';
  private $tree = array();
 
  public function __construct() {
    global $cPath, $cPath_array, $languages_id;
   
    if (isset($_SESSION['customer_id'])) {
      $customer_group_array = tep_get_customers_access_group($_SESSION['customer_id']);
    } else {
      $customer_group_array[] = 'G';
    }
    $sql = "SELECT c.categories_id, c.categories_image, cd.categories_name, c.parent_id
            FROM " . TABLE_CATEGORIES . " c,
                 " . TABLE_CATEGORIES_DESCRIPTION . " cd
            WHERE c.parent_id = 0
              and c.categories_id = cd.categories_id
              and cd.language_id = " . (int)$languages_id;
    $sql .= tep_get_access_sql('c.products_group_access', $customer_group_array);
    $sql .= "ORDER BY sort_order, cd.categories_name";
    $query = tep_db_query($sql);
    while ($categories = tep_db_fetch_array($query)) {
      $this->tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
                                                  'parent' => $categories['parent_id'],
                                                  'level' => 0,
                                                  'path' => $categories['categories_id'],
                                                  'image' => $categories['categories_image'],//<--Lango Added for Image Mod -->
                                                  'next_id' => false);
      if (isset($parent_id)) {
        $this->tree[$parent_id]['next_id'] = $categories['categories_id'];
      }
      $parent_id = $categories['categories_id'];
      if ( ! isset($first_element)) {
        $first_element = $categories['categories_id'];
      }
    }
   
    if (tep_not_null($cPath)) {
      $new_path = '';
      reset($cPath_array);
      while (list($key, $value) = each($cPath_array)) {
        unset($parent_id);
        unset($first_id);
        $query = tep_db_query("SELECT c.categories_id, c.categories_image, cd.categories_name, c.parent_id
                                          FROM " . TABLE_CATEGORIES . " c,
                                               " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                          WHERE c.parent_id = " . (int)$value . "
                                            and c.categories_id = cd.categories_id
                                            and cd.language_id = " . (int)$languages_id . "
                                          ORDER BY sort_order, cd.categories_name");
        if (tep_db_num_rows($query)) {
          $new_path .= $value;
          while ($row = tep_db_fetch_array($query)) {
            $this->tree[$row['categories_id']] = array('name' => $row['categories_name'],
                                                 'parent' => $row['parent_id'],
                                                 'level' => $key+1,
                                                 'path' => $new_path . '_' . $row['categories_id'],
                         // 'image' => $row['categories_image'],//<--Lango Added for Image Mod, uncomment for sub cats image -->
                                                 'next_id' => false);
            if (isset($parent_id)) {
              $this->tree[$parent_id]['next_id'] = $row['categories_id'];
            }
            $parent_id = $row['categories_id'];
            if ( ! isset($first_id)) {
              $first_id = $row['categories_id'];
            }
            $last_id = $row['categories_id'];
          }
          $this->tree[$last_id]['next_id'] = $this->tree[$value]['next_id'];
          $this->tree[$value]['next_id'] = $first_id;
          $new_path .= '_';
        } else {
          break;
        }
      }
    }
    $this->build_categories_string($first_element);
  } // end of __construct
 
  private function build_categories_string($counter) {
    global $cPath_array, $column_location;
    // end background variables
    $this->categories_string .= '<tr><td style="padding-right:5px;">';

//<----- Lango Added for Image Mod BOF------>
    $this->categories_string .= tep_image(DIR_WS_IMAGES . $this->tree[$counter]['image'], $this->tree[$counter]['name'], '30', '30');
//<----- Lango Added for Image Mod EOF------>

    for ($i=0; $i<$this->tree[$counter]['level']; $i++) {
      $this->categories_string .= "&nbsp;-&nbsp;";
    }
    $this->categories_string .= '</td><td class="' . $column_location . 'category"><a href="';
    if ($this->tree[$counter]['parent'] == 0) {
      $cPath_new = 'cPath=' . $counter;
    } else {
      $cPath_new = 'cPath=' . $this->tree[$counter]['path'];
    }
    $this->categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
    if (isset($cPath_array) && in_array($counter, $cPath_array)) {
      $this->categories_string .= '<b><u>';
    }
    // display category name
    $this->categories_string .= $this->tree[$counter]['name'];
    if (isset($cPath_array) && in_array($counter, $cPath_array)) {
      $this->categories_string .= '</u></b>';
    }
    $this->categories_string .= '</a>';
    if (SHOW_COUNTS == 'true') {
      $products_in_category = tep_count_products_in_category($counter);
      if ($products_in_category > 0) {
        $this->categories_string .= '&nbsp;<span class="category_count">(' . $products_in_category . ')</span>';
      }
    }
    $this->categories_string .= '</td></tr>' . "\n";
   
    if ($this->tree[$counter]['next_id'] != false) {
      $this->build_categories_string($this->tree[$counter]['next_id']);
    }
   
  } //end of build_categories_string

} // end of class
?>

_________________
CSS Store - http://mdjl40.mdjl-demo.co.uk -Work in Progress
YMM Filter Lists - http://mdjl-demo.co.uk/6-4-1a -Pagnation/Filter Lists


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Fri Jul 23, 2010 3:03 am 
Offline
CRE Newbie

Joined: Fri Apr 23, 2010 10:36 am
Posts: 22
Awesome! thanks a lot TheLango
I will give this a go on my local test site and see if I can get it working.

Much appreciated.

Cheers!


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Fri Jul 23, 2010 3:57 am 
Offline
CRE Talented

Joined: Sun Nov 29, 2009 10:57 am
Posts: 348
No Probs,
Let us know how you get on and how easy it was to achieve.

_________________
CSS Store - http://mdjl40.mdjl-demo.co.uk -Work in Progress
YMM Filter Lists - http://mdjl-demo.co.uk/6-4-1a -Pagnation/Filter Lists


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Tue Jul 27, 2010 6:30 am 
Offline
CRE Newbie

Joined: Fri Apr 23, 2010 10:36 am
Posts: 22
Hi thelango,
I'm not having too much success here because I dont realy understand code beyond removing some sections and adding minor tweaks.
I get this error when I try to impliment the file:

Fatal error: Call to undefined function tep_get_access_sql() in C:\webserver\xampp\htdocs\catalog1\includes\classes\box_categories.php on line 31


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Wed Jul 28, 2010 1:39 am 
Offline
CRE Talented

Joined: Sun Nov 29, 2009 10:57 am
Posts: 348
Thats probably my fault... I didnt ask what version you are running..

So what version are you running?



I wish CRE would have a place for each version!!!!!!!!!!

_________________
CSS Store - http://mdjl40.mdjl-demo.co.uk -Work in Progress
YMM Filter Lists - http://mdjl-demo.co.uk/6-4-1a -Pagnation/Filter Lists


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Wed Jul 28, 2010 2:52 am 
Offline
CRE Newbie

Joined: Fri Apr 23, 2010 10:36 am
Posts: 22
No problem, I'm running Pro v6.4.1a

Pretty much stock standard with my own minor modifications to the template.


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Wed Jul 28, 2010 3:29 am 
Offline
CRE Newbie

Joined: Fri Apr 23, 2010 10:36 am
Posts: 22
I'm using CE v6.4.1a on my test server (which is where I tried the code) I hope this will not cause issues...


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Wed Jul 28, 2010 4:51 am 
Offline
CRE Talented

Joined: Sun Nov 29, 2009 10:57 am
Posts: 348
Sam,
The above code I posted wont work on the CE version has it has the check for customer access levels which the CE version does not have installed.

CE Version:

Code:
<?php
/*
  $Id: box_categories.php $

  CRE Loaded, Open Source E-Commerce Solutions
  http://www.creloaded.com

  Released under the GNU General Public License
 
  Proivdes the logic to populate the info box by the same name
*/
class box_categories {
  public $row_count = 0;
  public $categories_string = '';
  private $tree = array();
 
  public function __construct() {
    global $cPath, $cPath_array, $languages_id;
   
    $categories_query_raw = "SELECT c.categories_id, c.categories_image, cd.categories_name, c.parent_id
                             FROM " . TABLE_CATEGORIES . " c,
                                  " . TABLE_CATEGORIES_DESCRIPTION . " cd
                             WHERE c.parent_id = 0
                               and c.categories_id = cd.categories_id
                               and cd.language_id= " . (int)$languages_id . "
                             ORDER BY sort_order, cd.categories_name";
    $categories_query = tep_db_query($categories_query_raw);
   
    while ($categories = tep_db_fetch_array($categories_query)) {
      $this->tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
                                                  'parent' => $categories['parent_id'],
                                                  'level' => 0,
                                                  'path' => $categories['categories_id'],
                          'image' => $categories['categories_image'],//<--Lango Added for Image Mod -->
                                                  'next_id' => false);
      if (isset($parent_id)) {
        $this->tree[$parent_id]['next_id'] = $categories['categories_id'];
      }
      $parent_id = $categories['categories_id'];
      if ( ! isset($first_element)) {
        $first_element = $categories['categories_id'];
      }
    }
   
    if (tep_not_null($cPath)) {
      $new_path = '';
      reset($cPath_array);
      while (list($key, $value) = each($cPath_array)) {
        unset($parent_id);
        unset($first_id);
        $categories_query = tep_db_query("SELECT c.categories_id, c.categories_image, cd.categories_name, c.parent_id
                                          FROM " . TABLE_CATEGORIES . " c,
                                               " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                          WHERE c.parent_id = " . (int)$value . "
                                            and c.categories_id = cd.categories_id
                                            and cd.language_id = " . (int)$languages_id . "
                                          ORDER BY sort_order, cd.categories_name");
        if (tep_db_num_rows($categories_query)) {
          $new_path .= $value;
          while ($row = tep_db_fetch_array($categories_query)) {
            $this->tree[$row['categories_id']] = array('name' => $row['categories_name'],
                                                 'parent' => $row['parent_id'],
                                                 'level' => $key+1,
                                                 'path' => $new_path . '_' . $row['categories_id'],
                         // 'image' => $row['categories_image'],//<--Lango Added for Image Mod, uncomment for sub cats image -->
                                                 'next_id' => false);
            if (isset($parent_id)) {
              $this->tree[$parent_id]['next_id'] = $row['categories_id'];
            }
            $parent_id = $row['categories_id'];
            if ( ! isset($first_id)) {
              $first_id = $row['categories_id'];
            }
            $last_id = $row['categories_id'];
          }
          $this->tree[$last_id]['next_id'] = $this->tree[$value]['next_id'];
          $this->tree[$value]['next_id'] = $first_id;
          $new_path .= '_';
        } else {
          break;
        }
      }
    }
    $this->build_categories_string($first_element);
  } // end of __construct
 
private function build_categories_string($counter) {
    global $cPath_array, $column_location;
    // end background variables
    $this->categories_string .= '<tr><td style="padding-right:5px;">';

//<----- Lango Added for Image Mod BOF------>
    $this->categories_string .= tep_image(DIR_WS_IMAGES . $this->tree[$counter]['image'], $this->tree[$counter]['name'], '30', '30');
//<----- Lango Added for Image Mod EOF------>

    for ($i=0; $i<$this->tree[$counter]['level']; $i++) {
      $this->categories_string .= "&nbsp;-&nbsp;";
    }
    $this->categories_string .= '</td><td class="' . $column_location . 'category"><a href="';
    if ($this->tree[$counter]['parent'] == 0) {
      $cPath_new = 'cPath=' . $counter;
    } else {
      $cPath_new = 'cPath=' . $this->tree[$counter]['path'];
    }
    $this->categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
    if (isset($cPath_array) && in_array($counter, $cPath_array)) {
      $this->categories_string .= '<b><u>';
    }
    // display category name
    $this->categories_string .= $this->tree[$counter]['name'];
    if (isset($cPath_array) && in_array($counter, $cPath_array)) {
      $this->categories_string .= '</u></b>';
    }
    $this->categories_string .= '</a>';
    if (SHOW_COUNTS == 'true') {
      $products_in_category = tep_count_products_in_category($counter);
      if ($products_in_category > 0) {
        $this->categories_string .= '&nbsp;<span class="category_count">(' . $products_in_category . ')</span>';
      }
    }
    $this->categories_string .= '</td></tr>' . "\n";
   
    if ($this->tree[$counter]['next_id'] != false) {
      $this->build_categories_string($this->tree[$counter]['next_id']);
    }
   
  } //end of build_categories_string

} // end of class
?>


PS.. why have you got the ce version on your local machine and PRO on your live site?

_________________
CSS Store - http://mdjl40.mdjl-demo.co.uk -Work in Progress
YMM Filter Lists - http://mdjl-demo.co.uk/6-4-1a -Pagnation/Filter Lists


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Wed Jul 28, 2010 7:11 am 
Offline
CRE Newbie

Joined: Fri Apr 23, 2010 10:36 am
Posts: 22
Hi Thelango,
Thanks a lot for the updated code, I will give this a try now.

I was informed by admin that I would have to buy another licence to set up Pro on my local machine. Which I may do in the future but right now I'm on a bit of a tight budget to get this store up and running.

Will let you know how I get on, I really appreciate the help!


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Wed Jul 28, 2010 7:41 am 
Offline
CRE Newbie

Joined: Fri Apr 23, 2010 10:36 am
Posts: 22
Hey Thelango,
I feel a bit dense but I still cant get it to work... how/where do I define which images to use?

I made 3 new images: category_arrow_1, category_arrow_2 & category_arrow_3 for testing purposes.

My actual site has 8 categories and more will likely be added.


Top
 Profile  
 
 Post subject: Re: How can I add an image to each category in the left column?
PostPosted: Wed Jul 28, 2010 9:25 am 
Offline
CRE Talented

Joined: Sun Nov 29, 2009 10:57 am
Posts: 348
Sam,
the code uses the categories image you set in admin when defining the category image.

_________________
CSS Store - http://mdjl40.mdjl-demo.co.uk -Work in Progress
YMM Filter Lists - http://mdjl-demo.co.uk/6-4-1a -Pagnation/Filter Lists


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

Board index » Web Design and Development » Development Discussions

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
It is currently Tue Feb 07, 2012 10:46 am
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Login

Top Listing

1. Cart2Cart - Shopping...
    Category: Shopping Cart Database Conversion Scripts
    
2. Points & Rewards PLUS!...
    Category: Add-Ons
    
3. Configuration Server...
    Category: Fixes
    
4. Credit Card with CCV
    Category: Payment Modules
    
5. CC7333_ATS
    Category: Templates
    
Show more...

Follow Us on Twitter

An error occurred

Oops, an error seems to have occurred. We're sorry for any inconvenience this might have caused. If the error persists, feel free to tell us about it.

CRE Loaded Community Chat hosted by CRE Loaded.

Join now


Chat about what's on your mind. More about public chats.


© CRE Loaded is a product of Chain Reaction Ecommerce, Inc. Usage & Privacy Policy