Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

template sistem


Reply

6 Posts   1998 Views

Avatar
goransabo

31 October 2008 at 12:01am Community Member, 9 Posts

Hi!
I have one question about template system. Do I have option to create different graphical interface for each of menu category?
... like this:
- home have two columns in red and blue colors
- about-us have two columns and two rows with black and white colors
- ,...

Thank for help
Goran

Avatar
Hamish

31 October 2008 at 7:01am (Last edited: 31 October 2008 7:02am), Community Member, 712 Posts

Yes. If I've understood you correctly, for different pages to have different templates, you either:

* create new page types (eg extend Page) and make new template files with the same name or,
* use '[url=http://doc.silverstripe.com/doku.php?id=templates&s=render#calling_templates_from_php_code]renderWith[/url]' to apply different templates to the same page class.

Avatar
Willr

31 October 2008 at 3:38pm Forum Moderator, 5511 Posts

Or you can do something like this in your page.ss template

<body id="$URLSegment">

So that will output like body id="home and body id="about-us" then in your CSS you could do #home #blah {} , #about-us #blah {} to swap layouts

Avatar
goransabo

1 November 2008 at 11:44am Community Member, 9 Posts

Thank's

Avatar
goransabo

2 November 2008 at 2:11am (Last edited: 2 November 2008 3:56am), Community Member, 9 Posts

Hi!
I try to add this code but this sistem doesn't work.
(On domain http://www.modnidodatki.com)
I need something like:
- predstavitev using: Sunflower theme
- modni dodatki za žene using: hairdresser
- modni dodatki za moške using: GoldShire
- ,...
or someting less complicated :-)
I have one theme, but each of menu (pages and subpages) using one theme, but diferent html code

p.s. Sorry for my english ;-(

Avatar
Willr

3 November 2008 at 11:33am Forum Moderator, 5511 Posts

So you want different themes for different sections? if they are completely different themes you need to set a line - SSViewer::set_theme('themename'); What you might have to do is have a switch statement in your Page.php Controller in the init() function which does something like

switch($this->URLSegment) {
case 'home' :
SSViewer::set_theme('theme1');
break;

case 'otherpage':
SSViewer::set_theme('theme2');
break;
}