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?