Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Official thread for Great Categories


willross

Recommended Posts

Great contribution! Thanks Will!

 

Looks very good and working properly, but I am not managing to get the cat. name and number of items in it on the same line. ie

 

Hardware

(6)

Software

(4)

The infobox is more than wide enough however! I have tried a nbsp near line 88 in cat.php, but this does not seem to work. Any ideas? Thanks in advance,

 

Skylla

 

 

Hello,

Excuse for my English language.

Fault in it catalog/includes/boxes/categories.php

von 'Great Categories CSS v.2.1 vom 4.Aug.2005'

 

great_categories.jpg

catalog/includes/boxes/categories.php

 

find:

 

//category name
$categories_string .= $tree[$counter]['name'];



if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
  //end of active link
$categories_string .= '';
}

if (tep_has_category_subcategories($counter)) {
  $categories_string .= '';
}

$categories_string .= '</a>';

if (SHOW_COUNTS == 'true') {
  $products_in_category = tep_count_products_in_category($counter);
  if ($products_in_category > 0) {
	$categories_string .= '(' . $products_in_category . ')';
  }
}

  // $categories_string .= '<br>';
  $categories_string .= '</div>';

if ($tree[$counter]['next_id']) {
  tep_show_category($tree[$counter]['next_id']);
}
 }
?>
<!-- categories //-->

 

and change to:

 

//category name
$categories_string .= $tree[$counter]['name'];



if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
  //end of active link
$categories_string .= '';
}

if (tep_has_category_subcategories($counter)) {
  $categories_string .= '';
}

$categories_string .= '';

if (SHOW_COUNTS == 'true') {
  $products_in_category = tep_count_products_in_category($counter);
  if ($products_in_category > 0) {
	$categories_string .= '?(' . $products_in_category . ')';
  }
}

 $categories_string .= '</a>';
  $categories_string .= '</div>';

if ($tree[$counter]['next_id']) {
  tep_show_category($tree[$counter]['next_id']);
}
 }
?>
<!-- categories //-->

 

greets Franz

Link to comment
Share on other sites

  • 1 month later...
  • Replies 177
  • Created
  • Last Reply

Top Posters In This Topic

  • 3 weeks later...
Hello,

Excuse for my English language.

Fault in it catalog/includes/boxes/categories.php

von 'Great Categories CSS v.2.1 vom 4.Aug.2005'

 

great_categories.jpg

catalog/includes/boxes/categories.php

 

find:

 

//category name
$categories_string .= $tree[$counter]['name'];
if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
  //end of active link
$categories_string .= '';
}

if (tep_has_category_subcategories($counter)) {
  $categories_string .= '';
}

$categories_string .= '</a>';

if (SHOW_COUNTS == 'true') {
  $products_in_category = tep_count_products_in_category($counter);
  if ($products_in_category > 0) {
	$categories_string .= '(' . $products_in_category . ')';
  }
}

  // $categories_string .= '<br>';
  $categories_string .= '</div>';

if ($tree[$counter]['next_id']) {
  tep_show_category($tree[$counter]['next_id']);
}
 }
?>
<!-- categories //-->

 

and change to:

 

//category name
$categories_string .= $tree[$counter]['name'];
if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
  //end of active link
$categories_string .= '';
}

if (tep_has_category_subcategories($counter)) {
  $categories_string .= '';
}

$categories_string .= '';

if (SHOW_COUNTS == 'true') {
  $products_in_category = tep_count_products_in_category($counter);
  if ($products_in_category > 0) {
	$categories_string .= ' (' . $products_in_category . ')';
  }
}

 $categories_string .= '</a>';
  $categories_string .= '</div>';

if ($tree[$counter]['next_id']) {
  tep_show_category($tree[$counter]['next_id']);
}
 }
?>
<!-- categories //-->

 

greets Franz

 

Hi Franz,

 

Just changed my catergories.php file according your changes.

The categorie count works okay now and don't wrap, but if i have longer names for my categories

i still have the same problem with wrapping too far to the left (so below the arrow).

Maybe you know what to change to get it correct?

 

Thank you very much!

Eric :D :D :D

Link to comment
Share on other sites

Hi Franz,

 

Just changed my catergories.php file according your changes.

The categorie count works okay now and don't wrap, but if i have longer names for my categories

i still have the same problem with wrapping too far to the left (so below the arrow).

Maybe you know what to change to get it correct?

 

Thank you very much!

Eric :D :D :D

Hi,

 

Back up first.

 

Try searching for NOWRAP and remove.

____________________________________________________________________

____________________________________________________________________

Link to comment
Share on other sites

Hi Franz,

 

Just changed my catergories.php file according your changes.

The categorie count works okay now and don't wrap, but if i have longer names for my categories

i still have the same problem with wrapping too far to the left (so below the arrow).

Maybe you know what to change to get it correct?

 

Thank you very much!

Eric :D :D :D

 

Hi,

 

Look for it :

 

if (tep_has_category_subcategories($counter) || $tree[$counter]['level'] == 0) {
	if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
	$categories_string .= '<span class="catwithsubs">'.tep_image(DIR_WS_IMAGES . 'categories/arrow_down.gif', '', '9', '9') . "</span>";
	} else {
	$categories_string .= '<span class="catwithsubs">'.tep_image(DIR_WS_IMAGES . 'categories/arrow_right.gif', '', '9', '9') . "</span>";
	}

 

 

Find this:

 

<span class="catwithsubs">

 

changes in:

 

<nobr><span class="catwithnosubs">

 

so that it looks like:

 

if (tep_has_category_subcategories($counter) || $tree[$counter]['level'] == 0) {
	if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
	$categories_string .= '<nobr><span class="catwithsubs">'.tep_image(DIR_WS_IMAGES . 'categories/arrow_down.gif', '', '9', '9') . "</span>";
	} else {
	$categories_string .= '<nobr><span class="catwithsubs">'.tep_image(DIR_WS_IMAGES . 'categories/arrow_right.gif', '', '9', '9') . "</span>";
	}
} else {
$categories_string .= '<nobr><span class="catwithnosubs">' .tep_image(DIR_WS_IMAGES . 'categories/arrow_bullet.gif', 'nokta', '9', '9') . "</span>";
}

 

greets Franz

Link to comment
Share on other sites

Hi,

 

Look for it :

 

if (tep_has_category_subcategories($counter) || $tree[$counter]['level'] == 0) {
	if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
	$categories_string .= '<span class="catwithsubs">'.tep_image(DIR_WS_IMAGES . 'categories/arrow_down.gif', '', '9', '9') . "</span>";
	} else {
	$categories_string .= '<span class="catwithsubs">'.tep_image(DIR_WS_IMAGES . 'categories/arrow_right.gif', '', '9', '9') . "</span>";
	}

Find this:

 

<span class="catwithsubs">

 

changes in:

 

<nobr><span class="catwithnosubs">

 

so that it looks like:

 

if (tep_has_category_subcategories($counter) || $tree[$counter]['level'] == 0) {
	if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
	$categories_string .= '<nobr><span class="catwithsubs">'.tep_image(DIR_WS_IMAGES . 'categories/arrow_down.gif', '', '9', '9') . "</span>";
	} else {
	$categories_string .= '<nobr><span class="catwithsubs">'.tep_image(DIR_WS_IMAGES . 'categories/arrow_right.gif', '', '9', '9') . "</span>";
	}
} else {
$categories_string .= '<nobr><span class="catwithnosubs">' .tep_image(DIR_WS_IMAGES . 'categories/arrow_bullet.gif', 'nokta', '9', '9') . "</span>";
}

 

greets Franz

 

Hi Franz,

 

Thank you for your help ;-)

I tried the changes you suggested, the names don't scroll down to the next line anymore

but now the category-box gets too wide...

I is not a problem long category names (with spaces in the name) goes down one line

but the problem for me is that the lower line doesn't line up nicely below the upper line,

it is too far to the left (below the arrow...)

 

Cheers,

Eric :D :blink: :blush:

Link to comment
Share on other sites

I'd like to add a link at the top of the category list, similar to what I have acheived at the bottom

 

Here's what I have got so far

cat01.gif

The circled bit at the bottom is okay, however the code I added duplicates the box title at the top, circled (categories).

 

In the top circle, is where I'd like my additional link. I want to add a link to an 'Alphabetical product list'. Can any one help me sort my code out to...

A...prevent the duplication of box title

B...add a link at the top of category list.

 

My code

The code is basically standard, except for my addition at the end, which I've marked with UncleSteve

<?php
/*
 $id: Great Categories v2.1 2005/07/09 14:00:00 willross Exp $
 http://www.palaia.com/ujp/ - [email protected]
 *** For use with standard install of osCommerce 2.2MS2+

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2005 osCommerce

 Released under the GNU General Public License
*/

 function tep_show_category($counter) {
global $tree, $categories_string, $cPath_array, $aa;

for ($a=0; $a<$tree[$counter]['level']; $a++) {
//	  $categories_string .= "  ";
}

//category start
  if ($tree[$counter]['level'] == 0)
{
	if ($aa == 1)
	{
  $categories_string .= '<img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="2"><br><img src="images/pixel_ltgray.gif" border="0" alt="" width="100%" height="1"><br><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="2">';
	}
	else
	{$aa=1;}

}


// display category name
if (tep_has_category_subcategories($counter) || $tree[$counter]['level'] == 0) {
	if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
	$categories_string .= '<table class="categ"><tr><td class="categ" nowrap>' . tep_image(DIR_WS_IMAGES . 'categories/arrow_down.gif', '', '9', '9') . " </td>";
	} else {
	$categories_string .= '<table class="categ"><tr><td class="categ" nowrap>' .tep_image(DIR_WS_IMAGES . 'categories/arrow_right.gif', '', '9', '9') . " </td>";
	}
} else {
$categories_string .= '<table class="categ"><tr><td class="categ" nowrap>  ' .tep_image(DIR_WS_IMAGES . 'categories/arrow_bullet.gif', 'nokta', '9', '9') . "</td>";
}


$categories_string .= '<td class="categ"><a href="';

if ($tree[$counter]['parent'] == 0) {
  $cPath_new = 'cPath=' . $counter;
} else {
  $cPath_new = 'cPath=' . $tree[$counter]['path'];
}

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

if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
  $categories_string .= '<b>';
}

//category name
$categories_string .= $tree[$counter]['name'];



if ( ($cPath_array) && (@in_array($counter, $cPath_array)) ) {
  $categories_string .= '</b>';
}

if (tep_has_category_subcategories($counter)) {
  $categories_string .= ' ';
}

$categories_string .= '</a>';

if (SHOW_COUNTS == 'true') {
  $products_in_category = tep_count_products_in_category($counter);
  if ($products_in_category > 0) {
	$categories_string .= ' (' . $products_in_category . ')';
  }
}

  // $categories_string .= '<br>';
  $categories_string .= '</td></tr></table>';

if ($tree[$counter]['next_id']) {
  tep_show_category($tree[$counter]['next_id']);
}
 }
?>
<!-- categories //-->
	  <tr>
		<td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('align' => 'left',
						   'text'  => BOX_HEADING_CATEGORIES);

 new infoBoxHeading($info_box_contents, true, false);

 $categories_string = '';

 $categories_query = tep_db_query("select c.categories_id, 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='" . $languages_id ."' order by sort_order, cd.categories_name");
 while ($categories = tep_db_fetch_array($categories_query))  {
$tree[$categories['categories_id']] = array(
									'name' => $categories['categories_name'],
									'parent' => $categories['parent_id'],
									'level' => 0,
									'path' => $categories['categories_id'],
									'next_id' => false);

if (isset($parent_id)) {
  $tree[$parent_id]['next_id'] = $categories['categories_id'];
}

$parent_id = $categories['categories_id'];

if (!isset($first_element)) {
  $first_element = $categories['categories_id'];
}
 }

 //------------------------
 if ($cPath) {
$cPath_array = split('_', $cPath);
reset($cPath_array);
while (list($key, $value) = each($cPath_array)) {
  $new_path .= $value;
  unset($parent_id);
  unset($first_id);
  $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $value . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name");
  $category_check = tep_db_num_rows($categories_query);
  while ($row = tep_db_fetch_array($categories_query)) {
	$tree[$row['categories_id']] = array(
										'name' => $row['categories_name'],
										'parent' => $row['parent_id'],
										'level' => $key+1,
										'path' => $new_path . '_' . $row['categories_id'],
										'next_id' => false
									   );

	if (isset($parent_id)) {
	  $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'];
  }
  if ($category_check != 0) {
	$tree[$last_id]['next_id'] = $tree[$value]['next_id'];
	$tree[$value]['next_id'] = $first_id;
  }

		 $new_path .= '_';
}
 }

tep_show_category($first_element);
$info_box_contents[] = array('align' => 'left',
					   'text'  => $categories_string);

//UncleSteve start of new code for links at bottom of cat list -----------------------------
// this code adds VIEW ALL PRODUCTS and PRINTABLE CATALOGUE at the bottom of the categories list

$info_box_contents[] = array('align' => 'center', 'text'  => 
'<HR><font size=-2><a href="' . 
tep_href_link(FILENAME_ALLPRODS, '', 'NONSSL') . '">' . 
BOX_INFORMATION_ALLPRODS . '</a></font>'. '<br>' . 
'<a href="' . 
tep_href_link(FILENAME_CATALOG_PRODUCTS_WITH_IMAGES, '', 'NONSSL') . '" >' . BOX_CATALOG_PRODUCTS_WITH_IMAGES . '</a>');

new infoBox($info_box_contents);

//UncleSteve end of new code for links at bottom of cat list -----------------------------

?>
		</td>
	  </tr>
<!-- categories_eof //-->

 

Thanks in advance of any help :)

____________________________________________________________________

____________________________________________________________________

Link to comment
Share on other sites

I'd like to add a link at the top of the category list, similar to what I have acheived at the bottom

 

Here's what I have got so far

cat01.gif

The circled bit at the bottom is okay, however the code I added duplicates the box title at the top, circled (categories).

 

In the top circle, is where I'd like my additional link. I want to add a link to an 'Alphabetical product list'. Can any one help me sort my code out to...

A...prevent the duplication of box title

B...add a link at the top of category list.

 

My code

The code is basically standard, except for my addition at the end, which I've marked with UncleSteve

snipped

 

Thanks in advance of any help :)

I found a cure to stop the duplication of the title, by inserting this

$info_box_contents = array();

after this line of code

 

new infoBoxHeading($info_box_contents, true, false);

But still need to insert a link above the categories.

 

Still looking for help :blink:

____________________________________________________________________

____________________________________________________________________

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
Hi Franz,

 

Thank you for your help ;-)

I tried the changes you suggested, the names don't scroll down to the next line anymore

but now the category-box gets too wide...

I is not a problem long category names (with spaces in the name) goes down one line

but the problem for me is that the lower line doesn't line up nicely below the upper line,

it is too far to the left (below the arrow...)

 

Cheers,

Eric :D :blink: :blush:

 

 

I gusses, I understand what you meant, Eric. I got the same problem using Schmoe's Great Categories CSS v2.1.

 

Without increasing the width of the column, and if the category name is too long, the second line of category move to far left, which doesn't look good. It does not actually indent well. but perhaps, other may find Schmoe's better.

 

I prefer Willross's version. it work fine for me so far.

 

I have unistalled the schmoe version and instill again the willross's Great Categories v2.1 Combo Pak. The problem solved.

 

cheers

jason

Link to comment
Share on other sites

  • 2 months later...
  • 4 months later...
Great work! I'm using a slightly modified version of your contribution on this site currently in development:

 

http://www.lotuspike.com/shop

 

Do you know how I can show all subcategories without having the user click on the first level category? I'd like it to display just like the navigation on the left of this page:

 

http://www.lotuspike.com/store.php

 

Is this possible?

 

I would also like to know how to display the second level of categories without the user having to click on the first.

 

Cheers.

Link to comment
Share on other sites

  • 3 months later...
  • 2 weeks later...

Hello,

 

i have 2 test sites here. One is a osCommerce 2.2MS2+ template that this contribution worked greatly.

 

However i have a template (9792, yes, that we all already saw on emule, etc) that, after thoses changes, nothing happened. I don't even know what the version is of that template. Can anyone help me out ?

 

if you want to see it: http://tognado.homelinux.org:1234/9792

 

 

tahnks in advance,

Thiago

Link to comment
Share on other sites

  • 2 weeks later...
Hello,

 

i have 2 test sites here. One is a osCommerce 2.2MS2+ template that this contribution worked greatly.

 

However i have a template (9792, yes, that we all already saw on emule, etc) that, after thoses changes, nothing happened. I don't even know what the version is of that template. Can anyone help me out ?

 

if you want to see it: http://tognado.homelinux.org:1234/9792

tahnks in advance,

Thiago

 

http://tognado.homelinux.org:8080/9792

 

I found out that the template version that this setup instructions doesn't works its the MONSTER 9792. It looks that menu is controlled by the ./includes/header.php

 

thanks,

thiago

Link to comment
Share on other sites

  • 5 weeks later...

Fantastic Contribution, have used for over a year. However, I am changing my site and want to hide subcategories from showing in the Categories box. Does anyone know the code to hide subcategories if you are using this contribution. I found the code for a stock install, however that doesnt translate to the this mod.

 

THanks in advance.

 

Rick

Link to comment
Share on other sites

  • 1 month later...

Hi,

Great contribution.

and now the BUT.

when I turn on caches I loose the categories. :'(

 

Can some one help???

 

I really like this and would hate to have to lose this module .

Thanks

Link to comment
Share on other sites

  • 4 months later...

Great contribution, but...

how to make this menu XHTML compliant?

 

HTML Tidy says:

 

Warning: <div> anchor "topcat" already defined

Warning: <div> anchor "topcat" already defined

Warning: <div> anchor "topcat" already defined

Warning: <div> anchor "topcat" already defined

Warning: <div> anchor "topcat" already defined

Warning: <div> anchor "topcat" already defined

...

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...

CSS version breaks HTML Validation

 

Hi willross and all who have contributed to this. Its (as many have said) exactly what I have been looking for.

 

I like both versions (CSS and non CSS) However, the CSS version breaks my HTML validation due to defining the TOPCAT, SECONDCAT, etc multiple times.

 

The error reported it this Error: ID "TOPCAT" already defined

 

I've looked through the code, but I don't see how to fix the problem. I'll keep thinking about it and post back here if I make any progress, but if anyone else has tried to get the code HTML Valid I'd be glad to hear about it.

 

Thanks again -

EDIT ->

Sorry just read your post Vali29 - missed that somehow before! Did you make an progress validating the CSS version?

 

Rob

Edited by teratyke
Link to comment
Share on other sites

  • 6 months later...

Hi, could somebody give me an advice for how to set the pics (arrow,rectangle,...) behind the words?

before: > Categorie

after: Catergorie >

 

Sorry, my PHP knowledge is`nt good enought for that...

Link to comment
Share on other sites

Hi all, I also think this is a great contribution.

 

I have a problem though. I have two stores, one is Osc v2.2 RC2a and this works great, however I have now placed this contribution into my old store which is Osc 2.2-MS2 and when the page first opens the categories are as they should be but as soon as I click something they go back to their default previous version.

 

I have viewed every page in this support thread and although someone else did have this problem on page 2 of the thread (melfalcon15) previously the answer for them did not work for me.

 

What I think the problem might be is that in my old store I have discovered that I have two stylesheet.css files. One is in the mystore folder and the other is in mystore/includes folder. I have done a file comparison of the two files and they are not exactly the same but very similar.

 

Basically the question is, should I add the code for this contribution to the second stylesheet.css file as well?

 

Why does the the older version have two stylesheet.css files anyway?

 

I have checked my new store and there is no extra stylesheet.css file in mystore/includes folder.

 

Thanks for any help, if anyone wants to view the files please let me know

 

Michael

Link to comment
Share on other sites

I dont know why but this has just started working as it should do. I did nothing since i made this post, strange but happy.

 

Thanks

 

Hi all, I also think this is a great contribution.

 

I have a problem though. I have two stores, one is Osc v2.2 RC2a and this works great, however I have now placed this contribution into my old store which is Osc 2.2-MS2 and when the page first opens the categories are as they should be but as soon as I click something they go back to their default previous version.

 

I have viewed every page in this support thread and although someone else did have this problem on page 2 of the thread (melfalcon15) previously the answer for them did not work for me.

 

What I think the problem might be is that in my old store I have discovered that I have two stylesheet.css files. One is in the mystore folder and the other is in mystore/includes folder. I have done a file comparison of the two files and they are not exactly the same but very similar.

 

Basically the question is, should I add the code for this contribution to the second stylesheet.css file as well?

 

Why does the the older version have two stylesheet.css files anyway?

 

I have checked my new store and there is no extra stylesheet.css file in mystore/includes folder.

 

Thanks for any help, if anyone wants to view the files please let me know

 

Michael

Link to comment
Share on other sites

  • 2 weeks later...

Hi all I have been through this thread looking for an answer to the categories wrapping to the next line. I have changed the width of the categories box to 200px from the default 125, I have changed all the advice given in various replies in this thread such as adding and removing NOWRAP, doing the change of

 

$categories_string .= ' (' . $products_in_category . ')';

in Line 80 of catalog/includes/boxes/categories.php,

also trying

There should be no way to wrap that. If so, use the old "nowrap" in the <td> or even older "<nobr>".

 

but nothing worked, the category names still wrapped until I tried changing this piece of code in catalog/stylesheet.css.

 

#thecategories {
				 position: relative;
				 top: -9px;
				 margin-bottom: -16px;
				 width: 180px;
			 }

 

by altering the code

width: 180px

lets me alters the available width of the categories box for my titles.

 

This will not automatically change your categories box to the desired width, it is a manual thing which you will need to amend depending on your titles but it will serve me ok for what I need.

 

Hope this helps someone.

 

Michael

Link to comment
Share on other sites

  • 2 months later...

hi will ross. I have downloaded the Zip files but I am very new to this sort of thing and need to be treated like a special child when it comes to the installation. It doesnt say in the read me file, where to install the gifs and as i am terrified of losing all our hard work, I would love you to instruct me further. please help, kind regards, Brian

 

www.cart.netne.net/catalog

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...