21280 Posts in 5729 Topics by 2600 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 822 Views |
-
Multiple templates for single page

28 August 2010 at 2:25am
I have some child pages (Concerts) set up and populated via the CMS, displaying via a Concerts.ss template. An example url would be /concerts/autumn-2010/.
I would like to display data from extra fields (already stored in the db) via a link on those pages to e.g. /concerts/autumn-2010/rehearsals, so I have a made suitable link in the Concerts.ss template:
<a href="$URLSegment/rehearsals/">Rehearsals</a>
Could someone possibly tell me where I go from here. I have a feeling it's renderWith but the following (in Concert.php) just gives me out of memory errors:
class Concert_Controller extends Page_Controller {
public function rehearsals(){
return $this->renderWith(array('Concert_rehearsals', 'Concert', 'Page'));
}
}
Many thanks. -
Re: Multiple templates for single page

28 August 2010 at 2:59am Last edited: 28 August 2010 3:01am
The method in your controller can be as simple as this:
public function rehearsals(){
return array();
}This will make the template-engine use the default naming convention for templates which is: ClassName_action.
So your template for the rehearsals should be named: Concert_rehearsals.ss
Update: Don't forget to append ?flush=1 to your URL to flush the template-cache.
-
Re: Multiple templates for single page

28 August 2010 at 4:05am
banal, thank you so much. I would never have guessed it could be so simple. I trawled the documentation for hours looking for a solution.
Now all I'll have to do is customise the Breadcrumbs a bit (unless one can pass something in that empty array to set things like the page title?).
Ed
-
Re: Multiple templates for single page

28 August 2010 at 4:31am
Yep, you should be able to pass custom content via that array.
So to override the title:return array('Title' => 'My custom Title');
| 822 Views | ||
|
Page:
1
|
Go to Top |


