Jump to content
Sign in to follow this  
Nils P.

[contribution] CategoryBoxEnhancement_v1.0 for 2.2 MS2

Recommended Posts

Panzerguy

 

Do you have the CategoryBoxEnhancement contribution installed. I already had that in there before making this mod.

 

Try testing to see what the values for $tree[$counter]['level'] and $catcount are for each of your categories but adding something like:

$categories_string .= $tree[$counter]['level'];
$categories_string .= "<br>";
$categories_string .= $catcount;
$categories_string .= "<br>";

After the $catcount++; line. When you run that you should see what the values are for these variables - this might help you to see whether the if statement should be returning an <hr> and if not, why not.

 

If you can't get anywhere, post the top 30 lines of your boxes/categories.php

 

Regards

Tim

Share this post


Link to post
Share on other sites

Thanks Tim,

 

After seeing your post I ran the test and was returning the correct values...why was it not working? This forced me to look harder at the code I had pasted and I realised I had done so incorrectly!

 

I substituted the correct code in the correct spot and voila...it worked!

 

Thanks again

Share this post


Link to post
Share on other sites
Matt

 

Thanks for that. It showed me where I needed to look to make the changes. I've had a play with it and come up with the following change to achieve the effect I want.

 

In boxes/categories.php line 20 is:

 

? ? global $tree, $categories_string, $cPath_array, $cat_name;

 

I have replaced this with:

? ? global $tree, $categories_string, $cPath_array, $cat_name, $catcount;

? ? $catcount++;

? ? if ($tree[$counter]['level'] == 0 && $catcount > 1){

? ? ? $categories_string .= "<hr size=1>";

? ? }

 

This adds a horizontal rule before each of the top level categories(except the first), splitting the category box up into a more readable list.

 

Hope this helps someone, someday.

Tim

here is a better code taken from other contribution for horizontal line

<hr size=1> give you too much space (ugly)

 

 

    global $tree, $categories_string, $cPath_array, $cat_name, $catcount;
   /// horizontal line
   $catcount++;
   if ($tree[$counter]['level'] == 0 && $catcount > 1){
      $categories_string .= '<img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="2"><br><img src="images/pixel_silver.gif" border="0" alt="" width="100%" height="1"><br><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="2">';
   }

Share this post


Link to post
Share on other sites

Hi,

Is it possible to invoke the categories without them being in the columns or in the box. I am using BTS, displaying the oscommerce store onto a HTML template so i would actually like to put the categories onto a designated corner. If I do that, can I still control the colour from stylesheet.css under Boxtext?

Anyway, before I get any further, how can I invoke them without them being in the columns or box?

Thanks a million guys.

Share this post


Link to post
Share on other sites

Hi Jacob,

I am using BTS.............. i would actually like to put the categories onto a designated corner. If I do that, can I still control the colour from stylesheet.css under Boxtext?

Anyway, before I get any further, how can I invoke them without them being in the columns or box?

Sounds more like a BTS question than a CategoriesBoxEnhancement question (but I think I understand how/why you got here). I rather not give you a detailed answer in this thread since it might confuse regular "CategoryBoxEnhancement" users.

 

But I think the answers to your questions are here http://forums.eeweb.nl/viewforum.php?f=17 (it's sort of BTS tutorial).

And if that's not what you are looking for you can ask more at the BTS support thread http://forums.oscommerce.com/index.php?showtopic=71930

 

hth

Paul

Edited by paulm2003

Share this post


Link to post
Share on other sites

I find a solution for the cache problem with the categories box and BTS, i change the code in /catalog/includes/functions/cache.php

 

find this line

 

function tep_cache_categories_box($auto_expire = false, $refresh = false) {

global $cPath, $language, $languages_id, $tree, $cPath_array, $categories_string, $cat_name;

 

change to:

 

function tep_cache_categories_box($auto_expire = false, $refresh = false) {

global $cPath, $language, $languages_id, $tree, $cPath_array, $categories_string, $cat_name, $boxContent;

 

thats all !! :D

Share this post


Link to post
Share on other sites

Great contribution...thanks :)

 

one quick question. I have been playing around with it on my site and it works great, including the additional info given above with the additional down arrow. I like the look when i highlight using background on the span error text in stylesheet so it highlights the name as i have it now in my site, but i'd like it more if the highlighting went all the way to the right instead of just over the text. I have extremely limited PHP knowledge at this point...can you tell me if there is a way for me to do edit it as such or do you have any suggestions as to where I could look?

 

Thanks in advance for any help you can provide :)

Share this post


Link to post
Share on other sites

Hello,

I have instaled the contribution and it is working fine.

But now i'm looking for somthing else: i want to have a different image for eache categorie, is this posible with this contribution or is there another contribution for that?

 

Dani?l

Share this post


Link to post
Share on other sites
i want to have a different image for eache categorie, is this posible with this contribution or is there another contribution for that?

I don't know if there's a contribution that explicitly does that. But it is possible with the original shop or with this contribution anyway. If you don't change your categories once you've set them up.

Share this post


Link to post
Share on other sites

Hello Nils,

Can you tel me what i have to chanche to the code to get the categorie image in front of the categorie name?

I want to have it like:

 

categories.gif

 

so in front of the head categorie an image and in front of all the sub categories an arrow.

 

Hope you can help me with tis, i have no clue howe to do this (php newbey).

 

Dani?l

Share this post


Link to post
Share on other sites

Hey Daniel,

 

first, don't be suprised too much if they delete or edit your post due to "explicit content"... ;)

 

Apart from that, this is what I'd do: I'd add a switch to the code in categories.php and ask for the specific cPaths of the categories in question, thus assigning a certain image to each one. As I said, you have to know the cPaths, and not do changes to the (top level) categories, or it will turn out wrong and you'll have to do it again. So maybe you should wait until you're sure about your top level categories and then give it a try. If you have no idea what I'm talking about, and you don't want to learn it, I'd recommend finding (and maybe paying) someone to do it for you.

 

Cheers,

Nils

Share this post


Link to post
Share on other sites

Hello Nils,

I have found another way to display the categorie image in front of the categorie name. In this way it is needed that the categorie image has the exact same name as the categorie.

 

This is the code i use now:

 

   if (tep_has_category_subcategories($counter)) {
     $boxContent .= tep_image(DIR_WS_IMAGES . $tree[$counter]['name']. '.gif', '');
   }
   else {
     $boxContent .= tep_image(DIR_WS_IMAGES . 'pointer_blue_light.gif', '');
   }

 

and when you want to use another image than the categorie image you can make the code as following:

 

   if (tep_has_category_subcategories($counter)) {
     $boxContent .= tep_image(DIR_WS_IMAGES . $tree[$counter]['name']. 'second.gif', '');
   }
   else {
     $boxContent .= tep_image(DIR_WS_IMAGES . 'pointer_blue_light.gif', '');
   }

 

when you have an categorie "pensel" you can upload an image named penselsecond.gif and thats the image he places in front of the categorie name now.

 

Hope you understand what i mean and have done and that this is usefull for someone.

 

Dani?l

Share this post


Link to post
Share on other sites

Daniel,

thanks, yes that's a pretty nice method, I didn't think about that one.

however, one should be aware that this:

 if (tep_has_category_subcategories($counter))

means that "if the category has subcategories", so if you have more than two levels of categories, it will try to display an extra image for categories that aren't top-level, and I doubt you'd want that to happen. However, for simple two-level structures, this is good enough ;)

Cheers,

Nils

Share this post


Link to post
Share on other sites

Hello Nils,

You are right, that is a little problem.

is there not a way i can tel the script somthing like:

if (tep_is_toplevel_category) {

So when the category is an toplevel categorie place that image, and else place the other image.

is sted off:

 

if (tep_has_category_subcategories($counter)) {

 

I'm going to have a look into that, when you no some nice way for this.... please tel me.

 

Dani?l

Share this post


Link to post
Share on other sites

Daniel,

 

Could you specify in which part of which code you added tat code?

Since i already modified everything very much, i don't want to make mistakes.

I want to try something similair, and i wonder where to put it exactly :)

 

Thanks, Zlack

Edited by zlack

It's easier to remember, then to forget

Share this post


Link to post
Share on other sites

Zlack, i use this to add images in front the category names.

 

Change your images size, vspace, etc. in the $consolicon variable and in every if ($tree[$counter]['path'] == NUMBER) Change the number to the your main categories numbers, and dont forget to change the images names for your images.

 

You can add this code just after

$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';

 

 

// Iconos de consolas

$consolicon= 'border="0" alt="' . $tree[$counter]['name'] . '" title="' . $tree[$counter]['name'] . '" width="25" height="22" vspace="2" align="absmiddle">';

if ($tree[$counter]['level'] < 1) {

if ($tree[$counter]['path'] == 21) {

$categories_string .= '<img src="images/tab_gc.gif" ' . $consolicon;

}

if ($tree[$counter]['path'] == 2) {

$categories_string .= '<img src="images/tab_xbox.gif" ' . $consolicon;

}

if ($tree[$counter]['path'] == 1) {

$categories_string .= '<img src="images/tab_ps2.gif" ' . $consolicon;

}

if ($tree[$counter]['path'] == 3) {

$categories_string .= '<img src="images/tab_ps1.gif" ' . $consolicon;

}

}

// Fin

Share this post


Link to post
Share on other sites

Hi Zlack,

search for:

 

     if (tep_has_category_subcategories($counter)) {
     $boxContent .= tep_image(DIR_WS_IMAGES . 'pointer_blue.gif', '');
   }

in catalog/includes/boxes/categories.php

 

and replace that with:

 

    if ($tree[$counter]['level'] < 1){
     $boxContent .= tep_image(DIR_WS_IMAGES . $tree[$counter]['name']. '.gif', '');
   }

 

and make sure that the categorie images are named exactly as the categorie name.

This is al you have to do.

 

Dani?l

Share this post


Link to post
Share on other sites

is this compatible with BTS 1.2? I cannot seem to get them working together?What changes need to be made if not?

Share this post


Link to post
Share on other sites

hi,

I have this working with the bts contribution.

i think there is an special bts version, but i'm not sure, just take a look into the contribution section.

 

Dani?l

Share this post


Link to post
Share on other sites

this was fixed just by adding the lines that are commented with addedBTSv1.2. There were two lines up top and a few lines at the bottom of the original categories.php file.

Share this post


Link to post
Share on other sites

How would you add a header image to the categories box? As many have pointed out if you use any of the contributions out there for adding images they over write the catagory.php file. Is there some where in the code where you could just add a line or two to add a header image to the box? I can get all of my other boxes working this is the only one I am having problems with

 

Cheers

Share this post


Link to post
Share on other sites

Is there anyway to add alt tags to the arrows?

If there is, how hard would it be to add the category name as the alt tag to each arrow, whether it be the category or the subcategory?

 

I have played around with the code a bit, but can not quite get it.

 

any suggestions would be great.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×