Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Hide some categories


Guest

Recommended Posts

Hi,

 

I need to hide the root categories in the left column, and only show the sub categories once an area is selected by a seperate map system.

 

I have an idea how this can be done but my PHP skills are very poor.

 

I think if i could add a check somewhere in

includes/boxes/categories.php

to say if a folder number is x,y or z dont display it.

 

I hope someone can help cos that code looks scary to me! :o

 

 

Trevor.

Link to comment
Share on other sites

Well I looked at the code and made the change from:

 

  $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");

 

Changed To:

 

$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.categories_id !='24' and 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");

 

Which does hide the category, but also hides all sub cats.

 

I think I need to edit the bit below so that all cats are received from the database but certain ones are not displayed onscreen (ie number 24) while thier subcats are displayed...

 

  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'];
   }
 }

 

any ideas?

Link to comment
Share on other sites

You should still be able to get to the subcats. Just turn the category back on, note what the subcat url is, turn it back off and see if you can still get to them. If you can use that url in your static navigation.

 

Iggy

Everything's funny but nothing's a joke...

Link to comment
Share on other sites

Yes I could do that but I want the subcats to be displayed as normal in the box.

 

On my website:

My Webpage

you can login with

[email protected]

pass: 123456

 

So I want the categories empty at first (no areas)

You select an area via the map

Then all the subcats of that area appear in the box

 

At the moment

S Perth

is hidden and can be selected from the map (Perth&Fremantle then Perth)

It does go into that area but no subcats are displayed in the categories box.

Link to comment
Share on other sites

I'm still not having any luck.

 

I've tried a few more ideas with no luck <_<

 

I think I need something like this (but this causes an error):

 

  $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))  {

// My code 
 if $categories['categories_id'] = '24' {$categories['categories_name']='';}
// End of my code

   $tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
                                               'parent' => $categories['parent_id'],
                                               'level' => 0,
                                               'path' => $categories['categories_id'],
                                               'next_id' => false);

 

Can you see why thats not working?

Or at least what I'm trying to do?

 

If the category number is 24 just display a space (or nothing) as its name.

 

Thats what I need to do.

Link to comment
Share on other sites

OK I just realised it should have been:

 

 if ($categories['categories_id'] = '24') {$categories['categories_name']='';}

 

:blush:

 

but that still doesn't work.

 

I think its in the wrong place and possibly using the wrong variables...

Link to comment
Share on other sites

I finally figured out a pretty inelegant but working solution.

 

I'll post it here just in case someone wants to do something similar and finds this thread:

 

 

This will hide all main categories (so you can select via another method) while leaving the categories box fully functional when you are inside a main category.

 

In Admin > Configuration > My Store - Change "Show Category Counts" to FALSE

 

 

 

REPLACE:

    if (tep_has_category_subcategories($counter)) {

      $categories_string .= '->';

 

WITH:

    if (tep_has_category_subcategories($counter)) {

      $categories_string .= '';

 

 

 

 

REPLACE:

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

 

WITH:

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

 

 

 

REPLACE:

  $categories_string .= '<br>';

 

WITH:

  if ($tree[$counter]['parent'] != 0) {    $categories_string .= '<br>';}

 

 

 

FOR A "CHANGE AREA" BUTTON:

 

JUST BEFORE:

new infoBox($info_box_contents);

 

ADD (and upload a button):

$info_box_contents[] = array('text' => '<div align="center"><a href="index.php"><img src="images/mine/button_change_area.gif" width="86" height="22" border="0"></a></div>');

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...