Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Remove Subcategories Listing Page

Remove Subcategories Listing Page

Locked

Views: 1,239

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
26 Aug 2010, 4:41 PM
#1
axxess avatar

axxess

New Zenner

Join Date:
Dec 2009
Posts:
19
Plugin Contributions:
0

Remove Subcategories Listing Page

I have search and haven't found the answer. I seems very simple but I am stumped. I would like users to be able to click on a category and go straight to all the listings in that category eliminating the subcategories page.

10 Sep 2010, 1:40 AM
#2
threddies_com avatar

threddies_com

New Zenner

Join Date:
May 2007
Posts:
28
Plugin Contributions:
0

Re: Remove Subcategories Listing Page

bump... i want to know, too!

10 Sep 2010, 3:51 AM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Remove Subcategories Listing Page

Then why do you have subcategories in that category?

10 Sep 2010, 11:30 AM
#4
threddies_com avatar

threddies_com

New Zenner

Join Date:
May 2007
Posts:
28
Plugin Contributions:
0

Re: Remove Subcategories Listing Page

i'm using the css dropdown menu, and want to force people to choose subcategories there. i don't want to have the option to click on the main category name to bring you to the subcategory listing pages at all. would appreciate any help - this is making me crazy!

maybe my issue is a little different from the original poster.....

10 Sep 2010, 1:25 PM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Remove Subcategories Listing Page

OK, so what you want is essentially to make the top category buttons in the dropdown to be not links. That should be possible with some logic added to tpl_drop_menu.php (I think that's the file). I can take a look at it, but it may be a few days before I have time to get into it.

11 Sep 2010, 1:36 PM
#6
threddies_com avatar

threddies_com

New Zenner

Join Date:
May 2007
Posts:
28
Plugin Contributions:
0

Re: Remove Subcategories Listing Page

that's exactly it - you stated it much more eloquently than i did! :P

i truly do appreciate any help. as i said, this has been totally driving me crazy!

12 Sep 2010, 3:39 AM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Remove Subcategories Listing Page

There are at least a couple of dropdown menu mods in Free Addons, so I would need to know exactly which one you are using before trying to modify files.

13 Sep 2010, 8:28 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Remove Subcategories Listing Page

tpl_drop_menu.php just calls /includes/classes/categories_ul_generator.php, and applies a few cryptic transformations to its output (for the categories part of the menu). It might be possible to intercept and alter the right one of those, but more likely the class will have to be edited. I would suggest you check with Jade (jettrue) in the support thread about this. Meanwhile, I'll take a look at it, but I make no promises for quick results.

14 Sep 2010, 1:11 AM
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Remove Subcategories Listing Page

   
    function buildBranch($parent_id, $level, $submenu=true, $parent_link='')
    {
        $result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '' );
        
        if (($this->data[$parent_id])) {
            foreach($this->data[$parent_id] as $category_id => $category) {
                $category_link = $parent_link . $category_id;
                if (($this->data[$category_id])) {
                    $result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
                } else {
                    $result .= sprintf($this->child_start_string, '');
                }
                //$result .= str_repeat($this->spacer_string, $this->spacer_multiplier * 1) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">';
                $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * 1) . ($parent_link? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">': '');
                $result .= $category['name'];
                //$result .= '</a>';
                $result .= ($parent_link? '</a>': '');
                  
                if (($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
                    $result .= $this->buildBranch($category_id, $level+1, $submenu, $category_link . '_');
                }
                $result .= $this->child_end_string;
            }
        }
        
        $result .= $this->parent_group_end_string;
        return $result;
    }
    

Add as shown in red to two lines:
($parent_link? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">': '')
($parent_link? '</a>': '')

This will disable the link if $parent_link is blank (the current category is a top category).

Please test and let me know how it works for you. If you have sub-subcats, this would not disable links on their parents (subcats). That would require a different approach, but might be achievable without much more complexity.

14 Sep 2010, 2:03 AM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Remove Subcategories Listing Page

This should determine whether there are more subcats:

COLOR="Red"[/COLOR] will be true (have content) if the current cat has subs, or false (blank) if not. Use it in a ternary operator similar to the above```php
function buildBranch($parent_id, $level, $submenu=true, $parent_link='')
{
$result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '' );

    if (($this->data[$parent_id])) {
        foreach($this->data[$parent_id] as $category_id => $category) {
            $category_link = $parent_link . $category_id;
            if (($this->data[$category_id])) {
                $result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
            } else {
                $result .= sprintf($this->child_start_string, '');
            }
            //$result .= str_repeat($this->spacer_string, $this->spacer_multiplier * 1) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">';
            $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * 1) . (($this->data[$category_id])? '': '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">');
            $result .= $category['name'];
            //$result .= '</a>';
            $result .= (($this->data[$category_id])? '': '</a>');
              
            if (($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
                $result .= $this->buildBranch($category_id, $level+1, $submenu, $category_link . '_');
            }
            $result .= $this->child_end_string;
        }
    }
    
    $result .= $this->parent_group_end_string;
    return $result;
}  
(($this->data[$category_id])?">[COLOR="Red"](($this->data[$category_id])? '': '</a>')

This should allow links only for cats with products, not with subcats.