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

Previewing themes


Go to End
Reply

9 Posts   2309 Views

Avatar
saimo

28 February 2008 at 10:01am Community Member, 67 Posts

Is it possible to preview a theme on a live site?
For example by using an URL parameter: (site)?theme=new-theme. I need this because I really think it's to much work getting remote access to my dev server working (running devserver localy in a linux box currently).

Avatar
Sigurd

29 February 2008 at 4:00pm Forum Moderator, 628 Posts

well demo.silverstripe.com does this with code. You'll notice all our silverstripe.com/themes can be previewed at the demo, right?

if(isset($_GET['theme'])) {
   $_SESSION['theme'] = $_GET['theme'];
}

$theme = isset($_SESSION['theme']) ? $_SESSION['theme'] : 'blackcandy';

SSViewer::set_theme($theme);

Avatar
ulysses

2 March 2008 at 4:09am Community Member, 57 Posts

if(isset($_GET['theme'])) {
$_SESSION['theme'] = $_GET['theme'];
}

$theme = isset($_SESSION['theme']) ? $_SESSION['theme'] : 'blackcandy';

SSViewer::set_theme($theme);

Which file do you add this code in?

Avatar
simon_w

2 March 2008 at 8:01am Forum Moderator, 474 Posts

mysite/_config.php instead of SSViewer::set_theme('blackcandy');

Avatar
ulysses

2 March 2008 at 9:38pm Community Member, 57 Posts

Hey thanks. That's great works like a charm.

Avatar
saimo

6 March 2008 at 8:12am Community Member, 67 Posts

Thanks for the reply. Sorry for my absence here, I've been away.

I'm gonna test it soon, but I have some things I need to do first. But I have no doubts that it will work, I even understand how it works:).

Avatar
ulysses

6 March 2008 at 10:34am Community Member, 57 Posts

I've got it working quite good with a family site I am building.

You need to create a hyperlink which links to each of the themes using the code:

?theme=plain
?theme=blackcandy
?theme=terrafirma

etc.

Avatar
saimo

6 March 2008 at 9:54pm Community Member, 67 Posts

Yes, that would be the way to go if I wanted a multitheme site, but as it is now I only need to preview the themes.

Go to Top