Controller recipes
If you want to make a page redirect to the first child page, below is a simple recipe to do so. index() is called automatically when the page is viewed - so you can do your redirection here.
class PageName_Controller extends Page_Controller { function index() { if($children = $this->Children()) { if($firstChild = $children->First()) { Director::redirect($firstChild->Link()); } } } }
It's very simple. It takes the first child - $this→Children()→First() if there are children of this page and redirects to that given first child page.
Sometimes working with SiteTree/Page is not practical, e.g. if you want to build a custom application-interface which isn't page- or content-oriented. This basically means using custom Controller-instances rather than ContentController to render your page-content. Pros:
Cons:
Usage of underscores in templates and controllers has several implications in the way sapphire handles it. See manifestbuilder (Autoloader) and templates for more information.
Please use comments for notes, tips and corrections about the described
functionality.
Use the Silverstripe Forum to
ask questions.