Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Screen size / resolution option

Screen size / resolution option

I have a rule setup for mobile browsers to load a specifically modified template but i was wondering if there was a way for chameleon to check the screen size or resolution to do the same?

AlmondDesign
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Screen size / resolution option

Yes and no. No, there's no built-in option to do it, and no, it's not easy to achieve. But Yes, it may be possible.

The basic problem is that browsers do not send the screen size and/or resolution to the web server when they send a normal HTTP request.

This means that the first response from the server to browser cannot respond to screen size/resolution.

If however you put some JavaScript onto the first (or any) page that the browser accesses in a session, then that JS could "call home" with AJAX, with more information about the browser or screen dimensions. The Ajax call could put the info into a session variable ready for the next page that gets generated.

Using this information, or if it's then in a cookie, then the next page generated has the information available and could make decisions using it.

Unfortunately there are some key problems left here:

1 - the "first page" problem. The first page generated in a session does not have dimension information. It simply can't have it.

2 - in an attempt to get around the "first page" problem, you might decide to make the 1st page do an automatic refresh, with the screen dimensions set in a cookie or sent back to the server in Ajax or post/get variable. However this comes with significant problems of its own:
- if the client does not have javascript and/or cookies enabled, then the server can't tell the difference between the page refresh and a brand new page request. The server may not be able to store anything in a session if cookies are disabled.
- Or the page may not refresh at all (no JS).
- Or searchbots are unable to index the page because they can't perform the requested refresh.

If anyone has any ingenious ways to work around these limitations then I'd be delighted to hear about them, and this would open the door to even more Chameleon conditions based on browser capabilities.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Re: Screen size / resolution option

How do the media-queries (css) get the Information?

Ferkels
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Screen size / resolution option

Media queries have direct access to various media capabilities. JS has the same access, I think. Both CSS and JS are client-side however, so if you need the server to act on them then you need a way for the client to communicate back to the server. This is normally done via cookies (so the data is sent with the next request), or via AJAX.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Posts this week:
4
User Info:
 
Total Users:
4383
Newest User:
kingpen99
Members Online:
0
Guests Online:
88

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked