21493 Posts in 5784 Topics by 2622 members
|Go to End|
5 April 2011 at 12:24pm Last edited: 5 April 2011 12:26pm
Most of the pages in the module I am building inherit from a single master page which contains common functions that all my pages share. I need to be able to access those functions from the rest of the pages with URL's like this (this is especially important for jquery):
To do that i used:
'masterpage' => 'masterpage_Controller',
But this also means users can type in this:
And navigate directly to my master page which shows a blank page without any content. It would be great if this page returned a 404 error instead or redirected people to the mainpage
I don't want to put in any code in the master page that could do that, as it would also affect all the other pages (I.E: if I placed ContentController::httpError(404) in there, then all my pages would return a 404)
Is there some way to tell silverstripe "don't let anyone go to this specific URL"?
7 April 2011 at 3:13am
If the page is in your site tree you can simply change the page type to redirector page and send it to where ever you like.
You could also set a redirect in the init() method of the controller and redirect based on the request url.
7 April 2011 at 9:52am
If I set the page up as a redirector page will I still be able to navigate to ww.site.com/masterpage/function and run that function? Or will it redirect anyone who tries to run the masterpage functions?
Also I already tried putting Director::redirect() in the init() method of the master page, but that has the adverse affect of making ALL of my pages redirect the user because they all extend from the master!
|Go to Top|