Category Menu - If Parent Category is marked as Hidden don't show Child Categories

5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 23, 2013   (RSS)

By Steve99 - October 17, 2013

Hello,

I have a dev site that I'm utilizing the Category Menu for. I've added the system field of "hidden".

If I mark a Parent Category as hidden, I want all Child Categories to then be hidden as well as we'd essentially be disabling a site section (without having to go through each Child Category to hide).

Is there a default option that can be set to achieve this? If not, I suppose I could use the "record_postsave" hook for a plugin.

Thank you in advance.

Regards,
Steve

By ross - October 17, 2013

Hi Steve

Thanks for posting!

There isn't a built in option to change all child categories to hidden if the parent is hidden. Like you mentioned, this could be done with a plugin that hooks in at "record_postsave". Is this something you'd like a hand with through consulting? Or are you ok on your own with it? We wouldn't be able to offer too much support if you do it on your own but we'll do everything we can :)

Let me know what you think :). Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By Steve99 - October 18, 2013

Hi Ross,

Thanks for the response. So I successfully wrote a beta plugin to handle this specific scenario (for a category setup with max depth of 2 - parent and one child). I've attached it for anyone to use, alter to their needs, or expand upon. I've only used this on a 2.53 install so I'm open for feedback on previous version testing.

After further thought, it would probably be in my best interest to handle this aspect in the front end versus database level. Too bad I came to this determination after coding a plugin for it...

On the front end is there anything built in for if a parent category is hidden then don't output the child categories of that parent? That way it wouldn't make them hidden at DB level, would be filtered through front end code.

Thanks, Ross!

Steve

Attachments:

categoryhide.php 2K

By ross - October 22, 2013

Hi Steve

Great plugin. Thanks for sharing it!

There isn't anything on the front end either to hide children of a hidden parent category so I think the plugin is probably the best way to do it. There is of course a way to code this all up on the front end but it will take a lot of work. There is less code over all doing it with a plugin :).

Does your plugin handle un-hiding children when you un-hide their parent? Or is that not a requirement?

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/