Zen Cart Logo
Forums / General Questions / Need to show sub-category list when using columnar view

Need to show sub-category list when using columnar view

Locked

Views: 2,324

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
29 Sep 2008, 2:01 AM
#1
davemehta avatar

davemehta

Zen Follower

Join Date:
Aug 2005
Posts:
130
Plugin Contributions:
0

Need to show sub-category list when using columnar view

So I installed the mod that shows all products listed under a category and that works great. Actually I need a list of the sub-categories to STILL BE DISPLAYED.

See how a listing of a category looks at my store here: http://www.indigogreenstore.com/index.php?main_page=index&cPath=1

It shows the category description and then all products. What I'd like is little textual links to all the sub-categories shown before the description. I did this in another small store by hard coding it in the tpl_index_product_list.php like this:

<?php  // THIS IS THE SUB-CATEGORY DROP-DOWN CODE I PUT IN, HAVE TO ENTER SUBCATS MANUALLY THO
	if ($_GET['cPath'] == "9999") {
	// TOPS CATEGORY
	echo <<< EOF
	<td width="440" align=right>
	<FORM name="davesForm">
	<select name="davesSelect">
		<option value="">Showing all Tops...</option>
		<option value="9_12">Casual</option>
		<option value="9_13">Shirts/Blouses</option>
		<option value="9_11">Strapless</option>
		<option value="9_10">Tees</option>
	</select>
	</FORM>
	</td>
EOF;
  } else if ($_GET['cPath'] == "99999") {
	// DRESSES CATEGORY
	echo <<< EOF
	<td width="440" align=right>
	<FORM name="davesForm">
	<select name="davesSelect">
		<option value="">Showing all Dresses...</option>
		<option value="1_5">Cocktail</option>
		<option value="1_3">Day</option>
		<option value="1_4">Evening</option>
	</select>
	</FORM>
	</td>
EOF;
  }
?>

Now that works, but as you can see I have to manually hard-code the sub-categories. Can someone provide the proper code to list the subcategories automatically given the category id? ALl it would be is an SQL query to the DB and pulling that info out, I'm just kind of lost how to do that in the Zen frame-work.

Thanks!

8 Oct 2008, 4:33 AM
#2
davemehta avatar

davemehta

Zen Follower

Join Date:
Aug 2005
Posts:
130
Plugin Contributions:
0

Re: Need to show sub-category list when using columnar view

I really need to figure this out guys... can anyone throw me a bone ... please :-(

8 Oct 2008, 4:06 PM
#3
davemehta avatar

davemehta

Zen Follower

Join Date:
Aug 2005
Posts:
130
Plugin Contributions:
0

Re: Need to show sub-category list when using columnar view

bump bump?

12 Oct 2008, 6:33 PM
#4
davemehta avatar

davemehta

Zen Follower

Join Date:
Aug 2005
Posts:
130
Plugin Contributions:
0

Re: Need to show sub-category list when using columnar view

Ok, so no one has answered and I've really tried to get this going on my own but am stuck against a wall. How about these questions... does anyone have an answer?

  1. How on the template page can I pull what master/parent category I am in?

  2. Using that parent category number I want to query the database to get a list of all it's sub-categories. What is the standard code to do a query from the zen-cart framework. I can call my own SQL query function but I'd rather use Zen's built-in functionality.

If I had these answers then I could just have it do a query for the subcategories and the link to the subcategory and thus show my list as I want.

I know this can't be that hard a task for you "master-zenners", please help? :-)

Here's what it looks like now:

Here's what I want to make it look like:

15 Oct 2008, 6:25 AM
#5
davemehta avatar

davemehta

Zen Follower

Join Date:
Aug 2005
Posts:
130
Plugin Contributions:
0

Re: Need to show sub-category list when using columnar view

Ok, so I got no one able to help and I spent ALL DAY on this and finally got something that worked... so I decided to share:

Here's the code you need to accomplish what I wanted:

<?php
	// This thing is based on the Simple Category Tree code mod. See the discussion thread at: http://www.zen-cart.com/forum/showthread.php?t=88215

	//$_SESSION['category_tree']->build_deepest_level_children(); // This is already built so we don't have to build it again!
	//$sub_cats = implode(',',$_SESSION['category_tree']->retrieve_deepest_level_children($cPath)); // This will give me a list of subcategory numbers, not needed for this
	$sub_cats = $_SESSION['category_tree']->build_category_string('', '', ' | ', $cPath, 1, false, true); // This is what gives me my list, see the includes/classes/simple_categories_tree.php file for the specific function and it's required variables
	
	if ($sub_cats != "") {
	   echo $sub_cats;
	}
?>