Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Categories and Subcategories


karabey

Recommended Posts

Posted

Hi,

 

I am trying to create a Bootstrap Theme for OSCommerce and have a Problem with the Categories.

With Bootstrap the Category with Subcategory should be build like below

 

<ul class="nav nav-pills nav-stacked">
<li class="active level1">Category
	<ul class="nav nav-pills nav-stacked">
		<li class="active level2">SubCategory1</li>
		<li>SubCategory2</li>
		<li>SubCategory3</li>
	</ul>
</li>
</ul>

 

At OSCommerce with my some Customization the Categories are looking like below.

 

function tep_show_category($counter) { global $tree, $categories_string, $cPath_array;
 for ($i=0; $i<$tree[$counter]['level']; $i++) {
$categories_string .= '<ul class="nav nav-pills nav-stacked">';
 }
 if (isset($cPath_array) && in_array($counter, $cPath_array)) {
$categories_string .= '<li class="active">';
 }
 else {
 $categories_string .= '<li>';
 }
 $categories_string .= '<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) . '">';

// display category name
 $categories_string .= $tree[$counter]['name'];
 if (tep_has_category_subcategories($counter)) {
$categories_string .= '+';
 }
 $categories_string .= '</a>';
 $categories_string .= '</li>';

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

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

 if ($tree[$counter]['next_id'] != false) {
$this->tep_show_category($tree[$counter]['next_id']);
 }
}

 

The SubCategories are created with the Code above like here

 

<ul class="nav nav-pills nav-stacked">
<li class="active level1">Category
	<ul class="nav nav-pills nav-stacked">
		<li class="active level2">SubCategory1</li>
	</ul>
	<ul class="nav nav-pills nav-stacked">
		<li class="active level2">SubCategory2</li>
	</ul>
	<ul class="nav nav-pills nav-stacked">
		<li class="active level2">SubCategory3</li>
	</ul>
</li>
</ul>

 

Should the SubCategories be seperated / extracted from the Category to set all < li > Tags into a < ul > Tag? Howelse could I set it with a small modification?

 

 

regards

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...