In the current version of vanilla, I can access pages (ie. /P5, /P4) that don't have content, I want to return 404 for those pages. How can I make this?
I thought about editing the class.discussioncontroller.php where I have the $ActualREsponses and do calculattion against the Comments.PerPage and get the Page number from the URL. For wrong page, return 404 via php. IS there any simpler way to do that?
This is common, the fancy pants titles are for your benefit.
Reason is, so that you cannot impersonate another user .. And parse diff url to cheat the system. Try typing it in, url that is and change in browser the title words !
Answers
maybe we can write something that return 404 if the result of the discussions array is empty
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •I thought about editing the class.discussioncontroller.php where I have the $ActualREsponses and do calculattion against the Comments.PerPage and get the Page number from the URL. For wrong page, return 404 via php. IS there any simpler way to do that?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •use hooks. look for a suitable Event in discussions Controller and hook into that event.
like
DiscussionsController_Render_Before($Sender) { $Offset = 0; $Limit = 10; $DiscussionModel = new DiscussionModel(); $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit, $Whereas); $CountDiscussions = count($DiscussionModel->Get($Offset, $Limit, $Whereas)); $Sender->Data('Discussions', $Sender->DiscussionData); $Sender->SetData('CountDiscussions', $CountDiscussions);above hook is to display only 10 discussions without pagination as an example.
you will have to look into whole code for discussionscontroller and hook it properly else it will be messed up
Theme Charcha for great desktop and mobile experience! - drop me a message :)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •PLEASE EXPLAIN. I can even get to that page by using this URL "http://vanillaforums.org/discussion/18968/how-to-return-404-for-non-existing-pages/p5" ,which is wrong.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Can or cannot ? Forums use a thread id system
This is common, the fancy pants titles are for your benefit.
Reason is, so that you cannot impersonate another user .. And parse diff url to cheat the system. Try typing it in, url that is and change in browser the title words !
Like this
http://vanillaforums.org/discussion/18968/omg-i-hijacked-osama-bin-laden/p5
422 Real Estate Australia , now open Check it out
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •How do I get the page number from the URL, the one that shows P5, so I want the number 5 into my variable
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •That wasnt your original question though, your after pagination. Dashboard set comments per page
422 Real Estate Australia , now open Check it out
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •no, of course not, I need it for the code that I'm building, so I can check the data against the URL page number
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •422 Real Estate Australia , now open Check it out
- Spam
- 1Abuse
- Troll
1 • Off Topic Insightful Awesome 2LOL •this is the funniest one yet @422. Thx for the comic relief. Its an oldie but a goodie, and perhaps the funniest reponse I've seen on the forum.
factoid: Most questions have been previously answered, try the search box first, please provide your Vanilla version Number!
Peregrine's Addons - donations gladly accepted for "successful solutions" and addons - kind of like tipping a waiter at a restaurant
- Spam
- Abuse
- Troll
2 • Off Topic Insightful Awesome 2LOL •Wonder why someone* marked it as abuse !
422 Real Estate Australia , now open Check it out
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •I see what the op is saying here. It would make for a cleaner experience. I would consider it low priority though since.
Crawlers are highly unlikely to crawl off the end of the page list since there are no links.
Returning a 404 error may make crawlers come back to the page less often which is bad for when there really is content.
This is exactly the kind of feature that pull requests are made for though ;)
- Spam
- Abuse
- Troll
1 • Off Topic 1Insightful Awesome LOL •