5121 Posts in 1527 Topics by 1119 members
| Go to End | ||
| Author | Topic: | 4764 Views |
-
Re: Alternative Redirect to First Child use

18 February 2012 at 9:58am
Its easier if you just stick this at the end of your page controller init function rather than use the template
public function init() {
parent::init();if($this->RedirectToChildOne && $this->Children()->Count()){
Director::redirect($this->Children()->First()->AbsoluteLink());This feature is invaluable if one is using jquerymobile since otherwise the root page is invisible and its content has to be moved to be its own first child
-
Re: Alternative Redirect to First Child use

20 March 2012 at 11:14am Last edited: 20 March 2012 11:15am
Hi, just in case anyone wants a variation...I just test to see if the page has any content, then redirect to the first child if not.
if(!$this->dbObject('Content')->hasValue()){
if($this->Children()->Count()){
Director::redirect($this->Children()->First()->AbsoluteLink());
}
}
| 4764 Views | ||
| Go to Top |
