Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Altering the how categories are displayed


Barido

Recommended Posts

I'm trying to get my categories view to look like this (without much success).

 

I've had a hack at altering the appropriate select statement and php in default.php, but it's a bit above my head.

 

If anyone could help out i'd really appreciate it.

Link to comment
Share on other sites

I tried looking at this page you sent the link for but it wouldnt open. I recognise the software and have seen abother site with what I think is the same menu as you are looking for.

 

http://www.cellnet.com.au

 

If this is what you are looking for I may have the solution for you.

 

PM me if you are interested.

Link to comment
Share on other sites

Craig,

 

I'm sure there are others that would be interested in your solution too. Please post it here.

Link to comment
Share on other sites

Kim,

 

Its not complete yet. Once its complete it will become a contribution.

 

If you want to see it you can view it on my website.

Link to comment
Share on other sites

I'm not after a menu as such, i'm wanting to change the main categories view.

 

Basically i need a select statement which given a value say 5...will select all the sub categories belonging to 5, and then list all the sub categories of those.

 

Here's a screenshot if you cannot view above url.

 

example.jpg

Link to comment
Share on other sites

I think this is what you are looking for:

http://www.oscommerce.com/community/contri...ions,236/page,3 (Main Categories)

 

I have it here:

www.redinstead.com.au

I would like to know how to have sub-sub categories show up too but I have no idea how to go about that.

 

I changed the code a bit thanks to Greg from TibetCollections (topic here: http://www.oscommerce.com/forums/viewtopic.php?t=29792)

 

These are the modifications that I made to includes/modules/main_categories.php to improve the layout:

Code:

<?php

/*

$Id: main_categories.php,v 1.0a 2002/08/01 10:37:00 Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com/

 

Copyright © 2002 Barreto

Gustavo Barreto <[email protected]>

http://www.barreto.net/

 

Based on: all_categories.php Ver. 1.6 by Christian Lescuyer

 

History: 1.0 Creation

1.0a Correction: Extra Carriage Returns

 

Released under the GNU General Public License

 

*/

 

// Preorder tree traversal

function preorder($cid, $level, $foo, $cpath)

{

global $categories_string, $HTTP_GET_VARS;

 

// Display link

if ($cid != 0) {

for ($i=0; $i<$level; $i++)

$categories_string .= '  ';

$categories_string .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath

=' . $cpath . $cid) . '">';

// 1.6 Are we on the "path" to selected category?

$bold = strstr($HTTP_GET_VARS['cPath'], $cpath . $cid . '_') || $HTTP_GET_VARS['cPath'] == $cpath . $cid;

// 1.6 If yes, use <b>

if ($bold)

$categories_string .= '<b>';

$categories_string .= $foo[$cid]['name'];

if ($bold)

$categories_string .= '</b>';

$categories_string .= '</a>';

// 1.4 SHOW_COUNTS is 'true' or 'false', not true or false

if (SHOW_COUNTS == 'true') {

$products_in_category = tep_count_products_in_category($cid);

if ($products_in_category > 0) {

$categories_string .= ' (' . $products_in_category . ')';

}

}

$categories_string .= '<br>';

}

 

// Traverse category tree

foreach ($foo as $key => $value) {

if ($foo[$key]['parent'] == $cid) {

// print "$key, $level, $cid, $cpath<br>";

preorder($key, $level+1, $foo, ($level != 0 ? $cpath . $cid . '_' : ''))

;

}

}

}

 

?>

<!-- main_categories //-->

<table width=100% border=0><tr>

<?php

 

//////////

// Get categories list

//////////

// 1.2 Test for presence of status field for compatibility with older versions

$status = tep_db_num_rows(tep_db_query('describe categories status'));

 

$query = "select c.categories_id, cd.categories_name, c.parent_id, c.category_big_image

from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION .

" cd

where c.categories_id = cd.categories_id";

// 1.3 Can't have 'where' in an if statement!

if ($status >0)

$query.= " and c.status = '1'";

$query.= " and cd.language_id='" . $languages_id ."'

order by sort_order, cd.categories_name";

 

$categories_query = tep_db_query($query);

 

 

// Initiate tree traverse

$categories_string = '';

preorder(0, 0, $foo, '');

 

//////////

// Display box contents

//////////

$info_box_contents = array();

 

$row = 0;

while ($categories = tep_db_fetch_array($categories_query)) {

if ($categories['parent_id'] == 0) {

$cPath_new = tep_get_path($categories['categories_id']);

$text_subcategories = '';

$subcategories_query = tep_db_query($query);

while ($subcategories = tep_db_fetch_array($subcategories_query)) {

if ($subcategories['parent_id'] == $categories['categories_id'])

{

$cPath_new_sub = "cPath=" . $categories['categories_id'] . "_"

. $subcategories['categories_id'];

 

$text_subcategories .= '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">' . $subcategories['categories_name'] . '</a>, ' . " ";

} // if

 

} // While Interno

$row++;

 

echo '<td valign=top width=100><a href="' . tep_href_link (FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $categories['category_big_image'], $categories['categories_name']) . '</a></td><td valign=top width=50% class="smallText"><font size=-1><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '"><b>' . $categories['categories_name'] . '</b></a></font><br><font size=-2>' . $text_subcategories . 'and <a href="' . tep_href_link (FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">more</a>!</font></td>';

if ((($row / 2) == floor($row / 2))) {

?>

</tr>

<tr>

<td colspan=6><img src="images/dot.gif" width=5 height=5></td>

</tr>

<?php

}

}

}

?>

 

</tr></table>

<!-- main_categories_eof //-->

 

 

Jen

I haven't lost my mind - I have it backed up on disk somewhere.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...