Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
How can I switch theme depending subdomains ?
Brice
March 2014
Hi FUELers ! I need your help.
Before beginning, sorry for my english, I'm a fuel french developer
;)
I've built a tree structure page with the nestedset Model.
Example :
Fruits
Orange
Cherry
etc....
Vegetables
Fish
I have :
- A Main Domain : food.com with a main menu : Fruits | Vegetables | Fish
I want
- A Subdomain : fruits.food.com with a main menu : Orange | Cherry | etc...
How can I make this :
food.com/fruits/orange -> fruits.food.com (a child website with the same structure but with a different Tree Root Node)
Where must i check the subdomain to switch theme and change my tree node route?
- In my Public_Controller with a router method
- Extend the Core Request Class?
Harro
March 2014
Accepted Answer
Pas de problème, Brice.
;-)
If it is only a switch of active theme, you can do that in the theme.php config file. After all, it's just a php file like any other.
It could be something simple like:
switch (\Input::server('host'))
{
case "food.com":
$theme = 'main';
break;
case "fruits.food.com":
$theme = 'fruits';
break;
default:
$theme = 'default';
}
return array(
'active' => $theme,
);
Or if you want it more clean, create a static helper class for it, and do:
return array(
'active' => \Themehelper::detect(),
);
and abstract the detection code away from the config file.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
March 2014