Welcome Guest, Not a member yet? Register   Sign In
How do i load different views?
#1

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
Be Simple Angel
Reply
#2

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
Reply
#3

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.
Be Simple Angel
Reply
#4

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.
Reply
#5

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.
Reply
#6

(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.
Be Simple Angel
Reply
#7

(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.
Be Simple Angel
Reply
#8

You should try bootstrap css or materialize css, both have good grid system & nice documentation.
Keep calm.
Reply
#9

I got it fixed.
Code:
if($_SERVER['HTTP_HOST'] = MOBILE_URL){
$view_folder = 'Mobile/;
}else{ $view_folder = 'Frontend/;
}
was the fix and it worked
Be Simple Angel
Reply




Theme © iAndrew 2016 - Forum software by © MyBB