[eluser]ndriana[/eluser]
Thanks Tpojka, it perfectly works. Here is my code:
Code:
protected function render($request, $template=NULL, $data=NULL){
$device = ($request['device'])? $request['device']: 'desktop';
$templName['template']=($template)? $template : 'default';
(file_exists(APPPATH . 'libraries/views/s_'.$device.'_lib.php'))?
$this->load->library('views/s_'.$device.'_lib', $templName, 'viewLib'):
$this->load->library('views/s_default_lib', $templName, 'viewLib');
$this->viewLib->load($data);
}
It's a little scrumbled but I'll go with it till I have time.
CroNiX> you are right, I should know but I am used to work with C++ and you never know what's inside of a given compiled library. It's a principle to check and CI automatically does it but it doesn't hand back the flag.
Also, I have filtered this code to its bone but my goal is to know the user's device and target them accordingly. Not as the basic like desktop, tablet, smartphone but it can go deeper as Samsung Galaxy S4 smartphone. And my theme would be similar to the device's interface.
There are long libraries you can use from the internet that will pinpoint to you the device and those libaries are updated time to time. So if their outputs are some random device like Huawei W1 and I haven't had time to work on that or they are not numerous enough to be targeted, I'd like the server to automatically fall back to the smartphone default theme.
And lastly, it is also a principle when working in team. Some collegues are just slow.