Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to show active categories


badjuju

Recommended Posts

Posted

Hi,

I applied a contrib that allows you to disable categories and it works. The only problem is I am using CoolMenu (dynamic pop-up menu) and it still shows the inactive categories in that menu.

 

If I click the category link, the image for the inactive categories do not show up - which is good.

 

I have looked at application_top.php file and changed the code so it only returns active categories, but it still does not work. I have also changed header_tags.php since there is a query there which builds the categories - no luck.

 

In coolmenu.php, I see this code:

$categories = tep_get_categories('');

 

My guess is it's taking the values in $categories, but there's no reference in the file how $categories was generated.

I'm not sure if this line of code queries the database or is using some value from a different page. I have looked at several files and no luck.

 

Please advice.

 

Thank you.

 

Below is the coolmenu.php file which replaces categories.php:

 

 

<?php

define('SHOW_COUNT','false');

define('SUB_CATEGORIES','4');



if (MAX_MANUFACTURERS_LIST < 2) {

   $cat_choose = array(array('id' => '', 'text' => BOX_CATEGORIES_CHOOSE));

} else {

   $cat_choose = '';

}



?>

 <script>



 oCMenu=new makeCM("oCMenu") //Making the menu object. Argument: menuname



 //Menu properties

 oCMenu.pxBetween=0

 oCMenu.fromLeft=6

 oCMenu.fromTop=186

 oCMenu.rows=0

 oCMenu.menuPlacement="left"



 oCMenu.offlineRoot=""

 oCMenu.onlineRoot=""

 oCMenu.resizeCheck=0

 oCMenu.wait=500

 oCMenu.fillImg="cm_fill.gif"

 oCMenu.zIndex=0



 //Background bar properties

 oCMenu.useBar=1

 oCMenu.barWidth="menu"

 oCMenu.barHeight="menu"

 oCMenu.barClass="clBar"

 oCMenu.barX="menu"

 oCMenu.barY="menu"

 oCMenu.barBorderX=0

 oCMenu.barBorderY=0

 oCMenu.barBorderClass=""



 oCMenu.level[0]=new cm_makeLevel()

 oCMenu.level[0].width=156

 oCMenu.level[0].height=20

 oCMenu.level[0].regClass="clLevel0"

 oCMenu.level[0].overClass="clLevel0over"

 oCMenu.level[0].borderX=1

 oCMenu.level[0].borderY=1

 oCMenu.level[0].borderClass="clLevel0border"

 oCMenu.level[0].offsetX=-20

 oCMenu.level[0].offsetY=10

 oCMenu.level[0].rows=0

 oCMenu.level[0].arrow="images/arrow.gif"

 oCMenu.level[0].arrowWidth=15

 oCMenu.level[0].arrowHeight=15

 oCMenu.level[0].align="right"

 oCMenu.level[0].filter="progid:DXImageTransform.Microsoft.Fade(duration=0.5)"

<?php

for ($i=1; $i<SUB_CATEGORIES; $i++) {

 echo'

	 oCMenu.level[' . $i . ']=new cm_makeLevel()

	 oCMenu.level[' . $i . '].width=150

	 oCMenu.level[' . $i . '].height=25

	 oCMenu.level[' . $i . '].regClass="clLevel1"

	 oCMenu.level[' . $i . '].overClass="clLevel1over"

	 oCMenu.level[' . $i . '].borderX=1

	 oCMenu.level[' . $i . '].borderY=1

	 oCMenu.level[' . $i . '].align="right"

	 oCMenu.level[' . $i . '].offsetX=-20

	 oCMenu.level[' . $i . '].offsetY=10

	 oCMenu.level[' . $i . '].borderClass="clLevel1border"

	 oCMenu.level[' . $i . '].align="right"

	 oCMenu.level[' . $i . '].filter="progid:DXImageTransform.Microsoft.Fade(duration=0.5)"





 ';

}  // end for



function blank_length($text) {

 $count = 0;

 while(substr($text, 0,12) == "  ") {

	 $text = substr($text, 12);

	 $count++;

 }

 return $count;

}





function print_menu_line($categories, $depth_size,$depth_parentid, $depth) {



 $size=0;

 for($i=0; $depth_size[$i]!=0; $i++) {

	 $size++;

 }





 echo "oCMenu.makeMenu('";



 if ($depth == 0) {

	 echo "top" . '_'.$depth_size[0] . "','','";

 } else if ($depth == 1) {

	 echo "sub" .'_'.$depth_size[0] .'_'. $depth_size[1] . "','top" .'_'. $depth_size[0] . "','";

 } else { // $depth < 1

	 echo "sub";

	 for ($i=0; $i<$size; $i++) {

   echo ($depth_size[$i] != 0) ? '_'.$depth_size[$i] : '_';

	 }

	 echo "','sub";

	 for ($i=0; $i<$size-1; $i++) {

   echo ($depth_size[$i] != 0) ? '_'.$depth_size[$i] : '_';

	 }

	 echo "','";

 }

 echo $categories['text'];

 if (SHOW_COUNT == 'true') {

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

	 if ($products_in_category > 0) {

   echo "<FONT COLOR="#000000">  (" . $products_in_category . ")</FONT>";

	 }

 }



       $cPathNew = "cPath=";

 for ($i=0; $i<$size-1; $i++) {

	 $cPathNew .= ($depth_size[$i] != 0) ? $depth_parentid[$i].'_':'';

       }

       $cPathNew .= $categories['id'];

 echo "','" . tep_href_link(FILENAME_DEFAULT,$cPathNew) . "')n";

}











 $categories = tep_get_categories('');

// $categories = tep_get_categories('categories_status = 1');



$height.= 1.70*count($categories);



$depth=0;

$blank_length;

$depth_size;

$depth_parentid;



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

// don't insert 1st entry ("please choose ...")

 $blank_length = blank_length($categories[$i]['text']);



 if($blank_length == $depth) {

	 $categories[$i]['depth'] = $depth;

	 $depth_size[$depth]++;

 } else if ($blank_length > $depth) {

	 $depth++;

	 $categories[$i]['depth'] = $depth;

	 $depth_size[$depth]++;

 } else if ($blank_length < $depth) {

	 for ($j=$depth; $j>$blank_length; $j--) {

   $depth_size[$j] = 0;

   $depth--;

	 }

	 $categories[$i]['depth'] = $depth;

	 $depth_size[$depth]++;



 }

        $depth_parentid[$categories[$i]['depth']] = $categories[$i]['id'];



 // remove blanks

 $categories[$i]['text'] = substr($categories[$i]['text'], 12*$blank_length);



 print_menu_line($categories[$i], $depth_size,$depth_parentid, $depth);

}







?>



 // create menu

 oCMenu.construct()



 </SCRIPT>

[/code]

  • 2 weeks later...
Posted

hi,,,

 

nice site!!.....

is that dhtml menu linked to your database..or.is it a static menu...

just wondering if that dhtml menu can be configue in the admin consol

are u able to add items from the admin consol...

 

also....

about your top blue menu site....about,,product,,,sponsors etc....

can u tell me how to create links...can u show me the scripts

 

thanks....

Posted

tep_get_categories is in includes/functions/general.php around line 510.

 

Hth,

Matt

Posted
hi,,,

 

nice site!!.....

is that dhtml menu linked to your database..or.is it a static menu...

just wondering if that dhtml menu can be configue in the admin consol

are u able to add items from the admin consol...

 

also....

about your top blue menu site....about,,product,,,sponsors etc....

can u tell me how to create links...can u show me the scripts

 

thanks....

 

The DHTML menu is based off the CoolMenu contrib - so all data is stored in the database. I also installed the contrib to enable/disable categories and had to change some files so that disabled items do not show up.

 

Regarding the links, I modified the image using Fireworks and applied the mouse-over effects. The script is actually the standard javascript code generated by fireworks.

Archived

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

×
×
  • Create New...