Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / changing Categories to Unordered nested list

changing Categories to Unordered nested list

Locked

Views: 1,823

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
12 Nov 2006, 5:37 AM
#1
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

changing Categories to Unordered nested list

I'm having quite a time getting this done. I've been editing the tpl_categories.php file for hours now. I keep coming sooo close to accomplishing this, but it's just out of my reach. This is as far as I seem to be able to get (not the whole thing, but the relevant section):

      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 .= '<li><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 .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
          $content .= $box_categories_array[$i]['name'] . '</a>' . "\n" . '<ul>' . "\n";
      }
        } else if ($box_categories_array[$i]['top'] !=='true') {        

        } else {

	  $content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
          $content .= $box_categories_array[$i]['name'] . '</a></li>' . "\n";
	} 

      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;
        }

      } 

	 if ($box_categories_array[$i]['top'] !=='true') { 
	$content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">' . $box_categories_array[$i]['name'] . '</a></li>' . "\n";

      } 

  }

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

  if (SHOW_CATEGORIES_BOX_SPECIALS == 'true' or SHOW_CATEGORIES_BOX_PRODUCTS_NEW == 'true' or SHOW_CATEGORIES_BOX_FEATURED_PRODUCTS == 'true' or SHOW_CATEGORIES_BOX_PRODUCTS_ALL == 'true') {
// display a separator between categories and links
    if (SHOW_CATEGORIES_SEPARATOR_LINK == '1') {
      $content .= '<hr id="catBoxDivider" />' . "\n";
    }

and this is what it outputs:

<ul class="sideBoxContent">
<li><a class="category-top" href="http://localhost/zencart/index.php?main_page=index&cPath=1">Greece</a>
<ul>
<li><a class="category-products" href="http://localhost/zencart/index.php?main_page=index&cPath=1_6">People</a></li>
<li><a class="category-products" href="http://localhost/zencart/index.php?main_page=index&cPath=1_7">Scenics</a></li>
<li><a class="category-top" href="http://localhost/zencart/index.php?main_page=index&cPath=2">Landscapes & Scenics</a></li>
<li><a class="category-top" href="http://localhost/zencart/index.php?main_page=index&cPath=3">Flowers & Leaves</a></li>

<li><a class="category-top" href="http://localhost/zencart/index.php?main_page=index&cPath=4">Abstracts</a></li>
<li><a class="category-top" href="http://localhost/zencart/index.php?main_page=index&cPath=5">Animals</a></li>
</ul>

As you can see, I have the list started, and I have the parent UL tag (for the categories with subs) - but I can't seem to find the place to put the closing ul and li tags for the sub cataegories and parents. It seems like it should be soooo simple - yet I can't seem to get it in there.

Would anyone have any suggestions for me? Pretty please?

12 Nov 2006, 5:49 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: changing Categories to Unordered nested list

If you are attempting what I think your are there is a module to do this and most is done via CSS... you might have a look as you really do not need to hace the code so drastically, and it might give you some insight.

See it here: Module

12 Nov 2006, 3:28 PM
#3
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: changing Categories to Unordered nested list

Thanks Kobra :)

I'll look at this module - maybe it'll give me some ideas. I'm not looking for a flyout menu, though - I just want to convert the sidebar menu to a nested list, nothing more :)

But thank you -and I'll report back with my findings :)

12 Nov 2006, 3:38 PM
#4
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: changing Categories to Unordered nested list

OMG Kobra - I could kiss you! I ued that module (sans the stylesheet and images stuff) and it does exactly what I need it to do. You are my hero for the day...you have no idea how much you have helped me!

Yay!

13 Nov 2006, 2:27 AM
#5
seethrou avatar

seethrou

Totally Zenned

Join Date:
May 2004
Location:
Hong Kong
Posts:
1,156
Plugin Contributions:
0

Re: changing Categories to Unordered nested list

Although it may not the info for this thread now, find that you are discussing moding categories menu sidebox, and also discussing in other thread for the display of categories and subcategories.

Please refer to the topics below for more references.
And hope that you find the solutions and share with up. :smile:

Yahootreemenu with ajax.
The mod now only use the basic tree menu of yahoo yui. However, if you have time you may change it to other menus of the yui for more functions.

always display subcategories in sidebox
A simple mod and always open up the categories and subcategories. In the above thread of yahoo yui mod also disscussed about this functions and provided with solution.

Category Groups Sidebox - downloadable
Another approach to mod the categories menu sidebox

13 Nov 2006, 4:02 AM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: changing Categories to Unordered nested list

seethrou,

Nice one there...I had not read closely enough and this may be more inline with what OP was looking for.

Guess I have to slow down and read postings more carefully...