Jump to content

How to make a site with different Themes?


clsource
 Share

Recommended Posts

Hello, 

I wish to know if you can make a site with different themes.

Eg. a blog site with a theme for summer, winter, fall and spring

So the admin could select the current theme.

Like the Admin Theme Module, but for the Front end.

Thanks :)

Link to comment
Share on other sites

I'm answering this quickly without thinking this through properly..... O0

Changing themes could mean either different HTML or different CSS or both....Whichever way,  you can do it either manually (admin makes change) or automatically.

Automated:

Seasons start and end on specific months/dates. PHP can tell what time/date/month/year it is. Hence, the process can be automated. If it is just CSS, you can have a conditional in your template file that checks the date and includes the right CSS for that season, e.g. if month is June, include this CSS, else....blah blah. Or use a switch statement + offer a default. This is quite easy to do. But, someone will have to at least visit the website for the change to be effected (or you can automate with a cron job)

Manually:

There are a couple of ways of doing this manually.

1. Set up a single page reference field which will only allow selection of child pages from one parent page called, e.g. "seasons". "season" child pages would be, the seasons  :-) - "summer", "winter", "autumn", "spring" - or however many seasons you have :D. Select a season and save. In your template file, you could do several things, e.g. have a conditional or an include like this .....include....path/to/your/{$seasonpagefield} . css....as an example, where $seasonpagefield returns the name of the selected season child page (which matches  the name of your CSS file). Or, if changing the markup too, you could include "summer.inc" or "spring.inc"...etc...you get the idea.

2. Use radio fields instead...The rest is the same.....

If doing it manually, you could even even set up a script to send admin an email to remind them to change the theme when the season changes...

Just some quick ideas but this should be very easy to do, I think....

  • Like 2
Link to comment
Share on other sites

I'm not sure I follow what you mean by being more scalable...I also don't get what you mean by admin config page. Are you talking about creating a module for this? One that can be configured in  admin/modules/ like the admin themes in PW 2.4? 

  • Like 1
Link to comment
Share on other sites

I'm not sure I follow what you mean by being more scalable...I also don't get what you mean by admin config page. Are you talking about creating a module for this? One that can be configured in  admin/modules/ like the admin themes in PW 2.4? 

Yes that behaviour.

an admin themes module but for the front-end site.

I guess in that case you must develop some module.

Link to comment
Share on other sites

Actually, if you want to control some bits and pieces, you can simply create a hidden page with a template (without a template file) and call it something like settings.

You could add a field, for instance, called site_title, and then call that field into perhaps your header of the site:

<title><?=$pages->get("/settings/")->site_title ?></title>

You could put other global bits in there like a name to call a theme css file and that sort of thing.

Don't need a module for that. I always create a page like that with global bits and pieces in it and then just call the fields into which ever template files.

  • Like 3
Link to comment
Share on other sites

Just to add (I feel like typing today!)...

You don't need to create a module unless you want something portable (or cool!  O0  :P). I had a feeling you wanted to hide your "themes" page from other users maybe...there you go, Joss gave you an answer...

I must admit I was very tempted to quickly rustle up a PW-Zen-garden-like site to show you how easy it is to do what you requested :-)... :)

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...