CodeIgniter Forums

Full Version: How do i load different views?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys, i have been strugling hard since yesterday to make his work but i am unable to do so.
here is a link to my question on SO.
anybody to help?
thanks
It seems to me that your code is working fine: BUT

Your first if statement is asking:
Code:
if($this->detect->isMobile() || $_SERVER['HTTP_HOST'] === MOBILE_URL){

Which is

Quote:if ((I detect it is a mobile device) OR (The url is a mobile url)) {  then give mobile content }

But, on your PC you fail the first test, but since you are using a mobile url, you pass the second test.

If you are suggesting that, on a PC, if I use the mobile url, I should get PC content, (which I do not think is right) you should recode it to do something like:

Quote:If (I detect it is a mobile device) { give mobile content }
else if (I detect it is a pc) { give pc content }
else (if it is a mobile url) {give mobile content}
else { give pc content }

I am making lots of assumptions about how you are detecting a mobile device, but the url only comes into play if it cannot detect the device type.

This is a waste of time though. I would always give mobile content if a mobile url is being used, whatever the device, just as you are currently doing.

Best wishes

Paul
Thanks for your reply and suggestion.
In fact what i want to achieve is:
1) show me mobile contents when i use mobile device or visit mobile url with a pc
2) show me pc contents when i visit with a pc on main domain url.
What results do you get when you output the results from

Code:
$this->detect->isMobile()
and
Code:
$_SERVER['HTTP_HOST'] === MOBILE_URL

If both are correct then the prob will be with set('base_url')

Paul.
Just because you can detect mobile usage doesn't mean you should. It is far better to use a CSS responsive web page.

The reasons for this assumption is because there are far too many screen sizes, far better to not use fixed widths and to make the web page fluid.

Search for "Google Mobile Friendly", submit you web page and follow the help to eliminate conflicts.

Easier to maintain a common web page rather than trying to cater for numerous screen sizes and resolutions.
(03-27-2016, 07:44 AM)PaulD Wrote: [ -> ]What results do you get when you output the results from

Code:
$this->detect->isMobile()
and
Code:
$_SERVER['HTTP_HOST'] === MOBILE_URL

If both are correct then the prob will be with set('base_url')

Paul.

On PC
Code:
$this->detect->isMobile()
returns false
and
Code:
$_SERVER['HTTP_HOST'] === MOBILE_URL
shows PC contents.

I think i'm finding a fix.
When it works i'll let you guys know about it.
(03-27-2016, 05:47 PM)John_Betong Wrote: [ -> ]Just because you can detect mobile usage doesn't mean you should. It is far better to use a CSS responsive web page.

The reasons for this assumption is because there are far too many screen sizes, far better to not use fixed widths and to make the web page fluid.

Search for "Google Mobile Friendly", submit you web page and follow the help to eliminate conflicts.

Easier to maintain a common web page rather than trying to cater for numerous screen sizes and resolutions.

i don't like responsive design because i am bad at css. In fact i don't like it at all.
You should try bootstrap css or materialize css, both have good grid system & nice documentation.
I got it fixed.
Code:
if($_SERVER['HTTP_HOST'] = MOBILE_URL){
$view_folder = 'Mobile/;
}else{ $view_folder = 'Frontend/;
}
was the fix and it worked