You are here:  » Subcatergories Index Page

Support Forum



Subcatergories Index Page

Submitted by stechew on Sat, 2010-11-13 10:29 in

Hi David,

I have created subcategories in sub folder in the index.php and I have p use this code http://www.pricetapestry.com/node/2161 for the index.php. I wish to have just only the subcategories in only 4 column without A-Z and all the categories combine into 4 column like show below.

Current Code:

{code saved}

Submitted by support on Mon, 2010-11-15 09:12

Hi,

If you don't require the A to Z layout, have a go with the following code

<?php
  $columns 
4;
  
$currentColumn 0;
  
$sql "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` WHERE category <> '' ORDER BY category";
  if (
database_querySelect($sql,$rows))
  {
    print 
"<table>";
    print 
"<tr>";
    foreach(
$rows as $product)
    {
      if (
$config_useRewrite)
      {
        
$href tapestry_hyphenate($product["category"])."/";
      }
      else
      {
        
$href "search.php?q=category:".urlencode($product["category"]).":";
      }
      print 
"<td><a href='".$href."'>".$product["category"]."</a></td>";
      
$currentColumn++;
      if (
$currentColumn == $columns)
      {
        print 
"</tr><tr>";
      }
    }
    print 
"</tr>";
    print 
"</table>";
  }
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com