Forums / General Questions / Custom categories sidebox

Custom categories sidebox

Started by dharrison on 11 Nov 2011, 12:09 PM · Views: 2,034

Results 1 to 20 of 22
11 Nov 2011, 12:09 PM
#1
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Custom categories sidebox

Hi all

I am using 1.3.9h version of zen cart. If you look at our home page http://ergonomiceducationfurniture.co.uk/, we are trying to set the category/image list (currently placed at the bottom of the page) on the right hand side column on the home page only.

Now if this already was a sidebox, I know how I would fix it. However, it isn't a sidebox. Please could anyone advise me how I can create the category image/list as a sidebox so I can add it to the right hand side.

I have a basic knowledge of PHP and MySQL so I am open to instruction.

Many thanks in advance.

Debbie Harrison
DVH Design | Web Design blog

11 Nov 2011, 3:19 PM
#2
gjh42 avatar

gjh42

Black Belt

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

Re: Custom categories sidebox

The stock categories sidebox fetches the category image, though it doesn't use it. You could modify /includes/templates/your_template/sideboxes/tpl_categories.php to add $box_categories_array[$i]['image'] to the output in the position you want. (I believe that is the right field - away from home now.)

If you want the images only on the homepage, you could wrap this addition in a test like

if ($this_is_home_page) {
//add image code
}

6 Dec 2011, 1:08 PM
#3
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Custom categories sidebox

Thanks gjh42 but what I was thinking of was moving the index_categories.php so it sits on the right hand side rather than at the bottom of the page which it currently does.

Take a look at http://ergonomiceducationfurniture.co.uk/ and you'll see what I mean.

Debbie Harrison
DVH Design | Web Design blog

6 Dec 2011, 2:19 PM
#4
gjh42 avatar

gjh42

Black Belt

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

Re: Custom categories sidebox

I think it would be easier to add another categories sidebox and modify it than to move the main page content partially to the sidebar. If you never had any content in the sidebar, you could turn it off on the homepage and put the main content in two divs floated left and right. The shopping cart sidebox would interfere with that.
If you moved the cart and notifications sideboxes to the left sidebar, you could have more space for internal page main content and use the "right column" for the cat/image list on homepage.

You could install another categories sidebox like the CSS Flyout one for the left (restyle it as desired) and move the stock one to the right column with a test for $this_is_home_page and the $box_categories_array[$i]['image'] added.

6 Dec 2011, 2:37 PM
#5
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Custom categories sidebox

Ok maybe my programming doesn't extend beyond monkey see, monkey do.

I have created a duplicate categories file called categorieshom.php. How do I add it to the layout boxes controller page? and where do I add the if ($this_is_home_page) {
//add image code
}

Please advise.

Debbie Harrison
DVH Design | Web Design blog

6 Dec 2011, 4:42 PM
#6
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Custom categories sidebox

Alternatively, can your categories dressing addon be used for the same purpose? I would like to keep my category list throughout but just need the image and categories on this right hand side.

Please advise. :shocking:

Debbie Harrison
DVH Design | Web Design blog

6 Dec 2011, 4:45 PM
#7
tundria avatar

tundria

New Zenner

Join Date:
Dec 2011
Posts:
36
Plugin Contributions:
0

Re: Custom categories sidebox

can anyone tell me how can i create new post ,i am new to this forum
and i have an error that i need to fix asap
Thank you

:yes:

11 Dec 2011, 1:36 PM
#9
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Custom categories sidebox

Anyway after that little intermission, please advise how I can duplicate a categories list and set it up using (I assume?) is Layout Boxes Controller.

I tried to use your category dressing add-ons but in essence, thats really to style the actual categories list isn't it?

Please help.

Debbie Harrison
DVH Design | Web Design blog

11 Dec 2011, 3:17 PM
#10
gjh42 avatar

gjh42

Black Belt

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

Re: Custom categories sidebox

Yes, it does use the stock categories sidebox as its base. It is possible to use the ch_categories option to have two different sideboxes (I helped someone through that a year or two ago for a rather complex set of requirements), but your purpose might best be served with a simpler setup. Install the CSS Flyout Menu from Free Addons for your regular categories sidebox, and add $box_categories_array['image'] to the stock tpl_categories.php in three places.
/includes/templates/your_template/sideboxes/tpl_categories.php:```php
if ($box_categories_array[$i]['current']) {
if ($box_categories_array[$i]['has_sub_cat']) {
$content .= '<span class="category-subs-parent">' . $box_categories_array[$i]['name'] . '</span>';
} else {
$content .= '<span class="category-subs-selected">' . $box_categories_array[$i]['name'] . '</span>';
}
} else {
$content .= $box_categories_array[$i]['name'];
}

      if ($box_categories_array[$i]['current']) {
        if ($box_categories_array[$i]['has_sub_cat']) {
          $content .= '<span class="category-subs-parent">' . $box_categories_array['image'] . $box_categories_array[$i]['name'] . '</span>';
        } else {
          $content .= '<span class="category-subs-selected">' . $box_categories_array['image'] . $box_categories_array[$i]['name'] . '</span>';
        }
      } else {
        $content .= $box_categories_array['image'] . $box_categories_array[$i]['name'];
      }
```
Gotta run now - we're taking my girlfriend's grandkids to Disney on Ice.
11 Dec 2011, 3:34 PM
#11
get_em_fast avatar

get_em_fast

Totally Zenned

Join Date:
Dec 2006
Location:
Seligman, MO U.S.A.
Posts:
2,072
Plugin Contributions:
1

Re: Custom categories sidebox

Or...................if you want, you can pm me, and I can send you a copy of the CSS Flyout Menu with Jquery and Category images, that I have already have made up.

Teach them to shop and they will shop today;
Teach them to Zen and they will OWN a shop tomorrow!

14 Dec 2011, 11:46 AM
#12
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Custom categories sidebox

Thanks get em fast, I shall PM you :clap:

Debbie Harrison
DVH Design | Web Design blog

14 Dec 2011, 12:46 PM
#13
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Custom categories sidebox

I have added and styled the extra list, but the images aren't showing up and also the list is on every page and I only need it for the home page.

please advise.

Debbie Harrison
DVH Design | Web Design blog

14 Dec 2011, 3:13 PM
#14
gjh42 avatar

gjh42

Black Belt

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

Re: Custom categories sidebox

I don't know why the images wouldn't be showing, but you will need to add a test around the (I think) categories_css.php module file for if($this_is_home_page) { and } at the end of the file. If there is code like $show_categories_css = true; in the file, then just set the test to show true if home page and false if not.
If you need more help, post a section of the top of the file below the comment block.

15 Dec 2011, 9:28 AM
#15
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Custom categories sidebox

Ok for the home page only code, on categories_css.php I have

require_once (DIR_WS_CLASSES . 'categories_ul_generator.php');
  $zen_CategoriesUL = new zen_categories_ul_generator;
  $menulist = $zen_CategoriesUL->buildTree(true);

require($template->get_template_dir('tpl_categories_css.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_categories_css.php');

  $title = BOX_HEADING_CATEGORIES;
  $left_corner = false;
  $right_corner = false;
  $right_arrow = false;
  $title_link = false;

    require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
	
	// Deb Add start
	if($this_is_home_page) {
	$show categories_css = true;
	} else {
	$show categories_css = false;
	}
//Deb Add End

And it doesn't work (go easy on me - this was actually the first time I've added code to a page myself)

Also for the tpl_categories.php I have (1st section up til line 59) is:

 case ($box_categories_array[$i]['top'] == 'true'):
        $new_style = 'category-top';
        break;
      case ($box_categories_array[$i]['has_sub_cat']):
        $new_style = 'category-subs';
        break;
      default:
        $new_style = 'category-products';
      }
     if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
        // skip if this is for the document box (==3)
      } else {
      $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';

       if ($box_categories_array[$i]['current']) {
        if ($box_categories_array[$i]['has_sub_cat']) {
          $content .= '<span class="category-subs-parent">' . $box_categories_array['image'] . $box_categories_array[$i]['name'] . '</span>';
        } else {
          $content .= '<span class="category-subs-selected">' . $box_categories_array['image'] . $box_categories_array[$i]['name'] . '</span>';
        }
      } else {
        $content .= $box_categories_array['image'] . $box_categories_array[$i]['name'];
      }  

      if ($box_categories_array[$i]['has_sub_cat']) {
        $content .= CATEGORIES_SEPARATOR;
      }
     /* $content .= '</a>'; */

      if (SHOW_COUNTS == 'true') {
        if ((CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) {
          $content .= CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX;
        }
      }

      $content .= '</a><br />' . "\n";
    }
  }

And it isn't working.

Debbie Harrison
DVH Design | Web Design blog

15 Dec 2011, 9:46 AM
#16
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Custom categories sidebox

Actually I have added the categories_css.php and the sidebox disappears completely.

:oops:

Debbie Harrison
DVH Design | Web Design blog

15 Dec 2011, 1:38 PM
#17
gjh42 avatar

gjh42

Black Belt

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

Re: Custom categories sidebox

Assuming the php require_once (DIR_WS_CLASSES . 'categories_ul_generator.php'); is the first line of functional code after the comment block, you would put php if($this_is_home_page) { // Deb Add start above it, and ```php
} // Deb Add end


Also, you can delete the lines ```php
  $left_corner = false;
  $right_corner = false;
  $right_arrow = false;
``` as they are from an ancient version of standard sidebox files and do nothing in current versions.
16 Dec 2011, 10:18 AM
#18
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Custom categories sidebox

I now have

    if($this_is_home_page) { // Deb Add start 
	  require_once (DIR_WS_CLASSES . 'categories_ul_generator.php');
	      } // Deb Add end  
		  
  $zen_CategoriesUL = new zen_categories_ul_generator;
  $menulist = $zen_CategoriesUL->buildTree(true);

require($template->get_template_dir('tpl_categories_css.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_categories_css.php');

  $title = BOX_HEADING_CATEGORIES;

    require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);

And its still on every page. Is there any else function to add to that?

Debbie Harrison
DVH Design | Web Design blog

19 Dec 2011, 6:46 AM
#20
dharrison avatar

dharrison

Zen Follower

Join Date:
Mar 2009
Location:
Essex, UK
Posts:
448
Plugin Contributions:
0

Re: Custom categories sidebox

It works! Thank you so much. :clap::clap: You rock.

Debbie Harrison
DVH Design | Web Design blog