Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

echo main categories ... unboxed


suggs

Recommended Posts

Hi there,

I understand that

include(DIR_WS_BOXES . 'categories.php');

takes includes/boxes/categories.php and parses/formats it using ../classes/boxes.php

 

my question:

is there a quick way of echoing the main categories (...or the contents of other boxes) without having to tweak and/or ruin boxes.php?

 

something like:

include(WHATEVEROPTION . 'categories.php');

or something even easier..?

 

thanks a lot i.a

Link to comment
Share on other sites

as I keep on talking to myself, I might as well present myself the solution:

 

(1.) throw the following main_categories.php into includes/modules/:

<?
// main_categories.php start
$query_cat = tep_db_query("select * from " . TABLE_CATEGORIES . " order by categories_id") or die ("query failed");
$query_cat_desc = tep_db_query("select * from " . TABLE_CATEGORIES_DESCRIPTION . " order by categories_id") or die ("query failed");
$num = mysql_num_rows($query_cat);
for ($i=0; $i<$num; $i++)
{
$parent_id = mysql_result($query_cat, $i, "parent_id");
$categories_name = mysql_result($query_cat_desc, $i, "categories_name");
$categories_id = mysql_result($query_cat_desc, $i, "categories_id");
if($parent_id == 0)
print "<a href=\"index.php?cPath=$categories_id\" class=\"bg_red\">$categories_name</a>   \n";
}
mysql_close();
// main_categories.php end
?>

 

(2.) add the following line to includes/filenames.php:

define('FILENAME_MAIN_CATEGORIES', 'main_categories.php');

 

Now you are ... I mean: now I AM ready to include the main categories anywhere I want just by including this:

<?php include(DIR_WS_MODULES . FILENAME_MAIN_CATEGORIES); ?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...