Disabling Access to Root Category Pages with "Display Root Categories As Headings"
Is there any way to disable or redirect away from the category page for root categories that are displayed as headings (with that option checked in the Dashboard)? So if I have that ticked and the following structure:
- Header Category 1 <--- not a link on homepage
- Sub Category 1
- Sub Category 2
- Sub Category 3
Through the breadcrumbs, I can still get to: http://site.com/vanilla/forums/categories/header-category-1 and it displays "no discussions". That's dumb. Why does Vanilla even create breadcrumbs or render a page for categories used as headings? Is there any way to stop this?
Best Answer
-
hgtonight MVP
Put this in your themehooks file.
public function CategoriesController_BeforeGetDiscussions_Handler($Sender) { if(C('Vanilla.Categories.DoHeadings') && $Sender->Category->Depth == 1) { redirect('categories/all'); } }
You could also create a function on the Categories controller that emulates discussions but uses the referenced argument category as the "root" node. Just a thought
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
11
Answers
What version of Vanilla are you running?
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
2.0.18.4
You need to update to 2.0.18.8 for security reasons.
You can disable viewing privileges using the Category custom permissions in the dashboard. Will this work?
If not, what do you want to happen?
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Just updated.
I've disabled "View" permissions for the "Header Category 1", yet when I click on the Subcategory under it and then click the "Header Category 1" in the breadcrumb trail, I'm taken to http://site.com/vanilla/forums/categories/header-category-1 to a page that says "No Discussions Found".
What doesn't make any sense to me is why Vanilla would render a page (and links to get to a page) that is supposed to act as a dumb category heading.
What I'd love to have happen is to show a list of the recent discussions from all of the categories within that Header Category... but I'd be satisfied if it'd just redirect them to the /categories/all
Thanks for your help btw.
Put this in your themehooks file.
You could also create a function on the Categories controller that emulates discussions but uses the referenced argument category as the "root" node. Just a thought
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.