Jump to content

subcategory product display on ViewCat


Guest spicybrains

Recommended Posts

Guest spicybrains

right now, ViewCat shows something like this:

* Subcategory 1 (# products)

* Subcategory 2 (# products)

* Subcategory 3 (# products)

* Product A

* Product B

* Product C

what i want it to do, is show something like this:

* Subcategory 1

-- Subcategory 1 Product A

-- Subcategory 1 Product B

* Subcategory 2

-- Subcategory 2 Product A

-- Subcategory 2 Product B

-- Subcategory 2 Product C

-- Subcategory 2 Product D

* Subcategory 3

-- Subcategory 3 Product A

* Product A

* Product B

* Product C

i tried changing NO_PRODUCTS to being the html to make that, but it failed miserably. i haven't figured out how to access the subcategories' TXT_LINK_CATID in the template to force it there.

any and all help yall can give would be most appreciated!

Link to comment
Share on other sites

Guest spicybrains

ok, i guess that's the real problem, i really don't know how the templating code loops and where i would put it. like, stuff that doesn't need to loop within the subcategory (like category description and the category-set price/option stuff that i added in) i can access without any problems, but my attempts at looping have been less than sucessful.

i guess this probably should have been in request a mod rather than in skinning, but at least in 2, it was something easily done and so the transition to the 3.0 series has been frustrating...

my most recent unsuccessful attempt went like this:

// section of /includes/content/viewCat.inc.php

//------------------------------------------------------------

// foreign language & image code removed for brevity



// loop results

for ($i=0; $i<count($subCategories); $i++){

		   // make sure there are products for this subcategory

		   if($subCategories[$i]['noProducts']>0){ 								   



		 //get the prices

				$txt[$i] = "";

		if($subCategories[$i]['has_imp']>0) 

					$txt[$i] .= "<br/>$".$subCategories[$i]['has_imp'] ." per sample.";

		if($subCategories[$i]['has_5ml']>0) 

					$txt[$i] .= "<br/>$".$subCategories[$i]['has_5ml'] ." per 5ml bottle.";

		if($subCategories[$i]['has_10ml']>0) 

					$txt[$i] .= "<br/>$".$subCategories[$i]['has_10ml'] ." per 10ml bottle.<br/>";



		//get the subcategory products, yo! -- add rest later

		$sql="select name from CubeCart_inventory where cat_id=".$subCategories[$i]['cat_id'];

		$subCatProducts = "";

		$subCatProducts = $db->select($sql);

		

		$prods[$i]="";

		for($zed=0;$zed<count($subCatProducts);$zed++)

			  $prods[$i].= $subCatProducts[$zed]['name']."<br>";

		



			 //assign variables

				$view_cat->assign("TXT_LINK_CATID", $subCategories[$i]['cat_id']);

			$view_cat->assign("TXT_CATEGORY", validHTML($subCategories[$i]['cat_name']));

		$view_cat->assign("TXT_SCAT_DESC", $subCategories[$i]['cat_desc']);

		$view_cat->assign("NO_PRODUCTS", $subCategories[$i]['noProducts']);

		$view_cat->assign("TXT_SCAT_PRICE", $txt[$i]);

		$view_cat->assign("TXT_SCAT_PRODUCTS", $prods[$i]);

		

		$view_cat->parse("view_cat.sub_cats.sub_cats_loop");

		   }	



	} // end loop results



$view_cat->parse("view_cat.sub_cats");





<!-- section of /skins/skin/content/StyleTemplates/viewCat.tpl -->





	<!-- BEGIN: sub_cats_loop -->

		<a href="index.php?act=viewCat&amp;catId={TXT_LINK_CATID}" class="txtDefault" style="color:#790000;">{TXT_CATEGORY}</a> <br/>

<div class="txtContentDesc" style="text-align:left;">{TXT_SCAT_DESC}

{TXT_SCAT_PRICE}</div>

{TXT_SCAT_PRODUCTS}<br>  ---<br/>

	<!-- END: sub_cats_loop -->

what comes out is just

* Subcat 1

Subcat 1 Description

Subcat 1 Price

---

* Subcat 2

Subcat 2 Description

Subcat 2 Price

---

* Subcat 3

Subcat 3 Description

Subcat 3 Price

---

Product 1

Product 2

and there should be 4, 5, and 2 products listed, respectively, within the subcats.

i honestly don't know what's wrong because the products are there and are coming out correctly when i echo the sql statement & paste it into hte database. maybe i shouldn't be coding at 4am after working on my thesis project all night :errm:

thanks for the suggestion about the product menu mod, but that won't really work for what i'm doing layout-wise as i pretty much eliminated most of the boxes, and what boxes are there, aren't exactly they way they look in the default skins.

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
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...