Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

CSS Sub Cat Addon HELP


Guest

Recommended Posts

Posted

I have installed a templte i purcahsed from template monster.

 

It has the standard menu setup but i want to use the perm show sub cat mod.

 

Ive installed it and the test goes to small default, i looked through and cant find the class pointer to change.

 

Can someone look at the original and the mod files and tell me how to make the original sub cat like the mod or what or how to change the cat mod file so it shows the same setup at the original but showing all sub cats.

 

Sorry if this is confusing but im really confuesd myself i think.

 

Thanks

Stu

 

ORIGINAL categories.php

---------------------------

<?php

/*

$Id: categories.php 1739 2007-12-20 00:52:16Z hpdl $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

function tep_show_category($counter, $count) {

global $tree, $categories_string, $cPath_array;

 

if ($count == 0 ) $kk=' class="bg_list_un"'; else $kk=' class="bg_list"';

$count++;

 

$categories_string .= '<li'.$kk.'>';

 

for ($i=0; $i<$tree[$counter]['level']; $i++) {

$categories_string .= '<div>';

}

 

$categories_string .= '<a href="';

 

if ($tree[$counter]['parent'] == 0) {

$cPath_new = 'cPath=' . $counter;

} else {

$cPath_new = 'cPath=' . $tree[$counter]['path'];

}

 

$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';

 

if (isset($cPath_array) && in_array($counter, $cPath_array)) {

$categories_string .= '<b>';

}

 

// display category name

$categories_string .= $tree[$counter]['name'];

 

if (isset($cPath_array) && in_array($counter, $cPath_array)) {

$categories_string .= '</b>';

}

 

if (tep_has_category_subcategories($counter)) {

$categories_string .= '->';

}

 

 

 

if (SHOW_COUNTS == 'true') {

$products_in_category = tep_count_products_in_category($counter);

if ($products_in_category > 0) {

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

}

}

 

$categories_string .= '</a>';

 

for ($i=0; $i<$tree[$counter]['level']; $i++) {

$categories_string .= '</div>';

}

 

$categories_string .= '</li>';

 

if ($tree[$counter]['next_id'] != false) {

tep_show_category($tree[$counter]['next_id'], $count);

}

}

?>

<!-- categories //-->

<tr>

<td>

<?php

$info_box_contents = array();

$info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES);

 

new infoBoxHeading($info_box_contents, true, false);

 

$count = 0;

 

$categories_string = '';

$tree = array();

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

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

$tree[$categories['categories_id']] = array('name' => $categories['categories_name'],

'parent' => $categories['parent_id'],

'level' => 0,

'path' => $categories['categories_id'],

'next_id' => false);

 

if (isset($parent_id)) {

$tree[$parent_id]['next_id'] = $categories['categories_id'];

}

 

$parent_id = $categories['categories_id'];

 

if (!isset($first_element)) {

$first_element = $categories['categories_id'];

}

}

 

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

if (tep_not_null($cPath)) {

$new_path = '';

reset($cPath_array);

while (list($key, $value) = each($cPath_array)) {

unset($parent_id);

unset($first_id);

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

if (tep_db_num_rows($categories_query)) {

$new_path .= $value;

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

$tree[$row['categories_id']] = array('name' => $row['categories_name'],

'parent' => $row['parent_id'],

'level' => $key+1,

'path' => $new_path . '_' . $row['categories_id'],

'next_id' => false);

 

if (isset($parent_id)) {

$tree[$parent_id]['next_id'] = $row['categories_id'];

}

 

$parent_id = $row['categories_id'];

 

if (!isset($first_id)) {

$first_id = $row['categories_id'];

}

 

$last_id = $row['categories_id'];

}

$tree[$last_id]['next_id'] = $tree[$value]['next_id'];

$tree[$value]['next_id'] = $first_id;

$new_path .= '_';

} else {

break;

}

}

}

tep_show_category($first_element, $count);

 

$info_box_contents = array();

$info_box_contents[] = array('text' => '<ul class="categories">' . $categories_string . '</ul>');

 

new infoBox($info_box_contents);

?>

</td>

</tr>

<!-- categories_eof //-->

--------------------------------------------------------------------------------------------------------------------

 

 

 

 

------------------------

Show all sub cats by default Mod - categories.php

 

-----------------------

 

<?php

/*

$Id: show_subcategories.php,v 1.0 2003/01/08 10:37:00 Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com/

 

Based on: main_categories.php Ver. 1.0 by Gustavo Barreto

 

History: 1.0 Creation

CONTRIB 885 - show subcategories in menu

 

Released under the GNU General Public License

 

*/

 

// Preorder tree traversal

//befordch: unactivated not needed

/*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- this is for older snapshots pre-November 2002

/* 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 . '_' : ''))

;

} */

// Function used for post November 2002 snapshots

function tep_show_category($counter) {

global $foo, $categories_string, $id;

 

for ($a=0; $a<$foo[$counter]['level']; $a++)

$categories_string .= " ";

}

 

?>

<!-- show_subcategories //-->

<tr>

<td class="infoBox_left">

<?php

 

//////////

// Display box heading

//////////

$info_box_contents = array();

$info_box_contents[] = array('align' => 'left', 'text' => BOX_HEADING_CATEGORIES);

new infoBoxHeading($info_box_contents, true, false, false, true);

 

//////////

// 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')); used for older snapshots

$status = tep_db_num_rows(tep_db_query('describe ' . TABLE_CATEGORIES . ' status'));

 

$query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_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, ''); //bedfordch unactivated not needed

 

//////////

// Display box contents

//////////

$info_box_contents = array();

$row = 0;

$col = 0;

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

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

$temp_cPath_array = $cPath_array; //Johan's solution - kill the array but save it for the rest of the site

unset($cPath_array);

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

$text_subcategories = '<br>';

$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') . '" class="menusubcateg">' . '  ' . tep_image(DIR_WS_IMAGES . 'pointer_blue_light.gif', '') . $subcategories['categories_name'] . '</a>';

//start befordch fix (show subcategoriy count)

if (SHOW_COUNTS == 'true') {

$products_in_category = tep_count_products_in_category($subcategories['categories_id']);

if ($products_in_category > 0) {

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

}

}

//end bedfordch fix

$text_subcategories .= "<br>"; //bedfordch add <br> after subcategory.

$q2= "select * from categories where parent_id=" . $subcategories['categories_id'];

$rec2 = mysql_query($q2);

while ($rq2 = mysql_fetch_array($rec2)) {

$snd_sub_category = $rq2['categories_id'];

$q3= "select categories_name from categories_description where categories_id=" . $snd_sub_category;

$rec3 = mysql_query($q3);

$rq3 = mysql_fetch_array($rec3);

$snd_categories_name = $rq3[categories_name];

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

$text_subcategories .= '' . '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '" class="menusubcategsec">' . '   - ' . $snd_categories_name . '</a>' . "<br>";

}

}

} // While Interno

//start befordch fix (show category count)

$buildtext = ' <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '" class="menucateg"><b>' . ' ' . tep_image(DIR_WS_IMAGES . 'pointer_blue.gif', '') . $categories['categories_name'];

if (SHOW_COUNTS == 'true') {

$products_in_category = tep_count_products_in_category($categories['categories_id']);

if ($products_in_category > 0) {

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

}

}

//end bedfordch

$buildtext .= '</b></a>' . $text_subcategories;

$info_box_contents[$row] = array('align' => 'left',

'params' => 'class="smallText" width="130" valign="top"',

'text' => $buildtext); //befordch show category count

$col ++;

if ($col > 0){

$col = 0;

$row ++;

}

$cPath_array = $temp_cPath_array; //Re-enable the array for the rest of the code

}

}

new infoBox($info_box_contents, true);

?>

</td>

</tr>

<!-- show_subcategories_eof //-->

---------------------------------------------------------------------------------------------

Archived

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

×
×
  • Create New...