Multiple roles based on agent/carrier

Bensbury - November 13, 2009 - 04:15
Project:Mobile Tools
Version:6.x-1.9
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi,

I have mobile tools working great to handle the different Japanese phone carriers.
Recently I was asked to performance boost my site and I have been looking at the static page cache options.

So far I can't cache by theme, which totally wrecks the site.
However I found a module that might cache by role.
In fact I know Drupal must cache by role as authenticated users and anonymous users cache differently.

This means if I can give mobile users different roles based on their carrier I should be able to cache per phone type.

Now mobi tools can select different themes already depending on agent.

So....... if is possible to select/create roles based on agent?

Thanks.

#1

twom - November 15, 2009 - 20:44

Hi,

Thanks for this post. What you are talking about (namely caching) is currently a big issue in the Module.
Actually I was thinking of another solution (it also comes with some performance loss, but maybe acceptable).

When a request comes in, instead of switching the theme, you could redirect using a new argument ?mobile=true or maybe much more specific ?theme=themename. In that case the caching mechanism will cache the page seperatly:
Example:
http://www.domain.com and http://www.domain.com/?mobile=true will be a different item in the cache. The first one can be the standard theme while the second one can be the mobile theme.

The solution you suggest can also work. Currently I have a mobile role and a non mobile role in the mobile tools module, this means that you could use the caching per role module (I don't know the module exactly).

A third solution could be to write a custom caching module (this is possible in Drupal, but is best evaluated on a per site basis)

Regards,
Tom

PS: Can you explain your use case some more. What do you exactly mean with handling the different Japanese phone cariers?

#2

Bensbury - November 26, 2009 - 12:44

Does sending the argument ?theme=themename still switch the themes?

I'll explain my usage and then hopefully that will let you understand best what I could do:

I have a site with a PC theme and then multiple mobile themes (au | kddi | softbank).

1. Firstly, in Japan I have been told by my boss that using subdomains etc is not cool.
The mobile hits the site and the urls must stay the same whether mobile or PC.
(1st problem).
So I am using themes to switch the layout and so on.

*I opened up the module and added in the Japanese user agents.
We also attached the PEAR Net_userAgent package to it too, to get info about J-phones.

http://pear.php.net/package/Net_UserAgent_Mobile/

2. Japanese phones like to use J_shift encoding. So to conform to all the older phones, everything has to get converted to j_shift.
(the japanese mobile phone helper module does this)

3. Japanese phones don't allow cookies, sessions or Javascript and so you have to pass all the information in a big query.
(the japanese mobile phone helper module does this)

4. Also depending on the phone and carrier the J-phones render differently.
Mainly by carrier, and so different themes are used and template overrides put in to handle the carriers. For docomo I am told not to use CSS in order to support older phones.
If I could detect by phone info then more themes would be created.
CSS is also inline only.

If you look at www.anapnet.com it is a PC/mobile site that displays for all carriers.
It's built on a custom CMS but I want Drupal to be able to handle Japanese sites and Mobile.

To do so I need to be able to handle the carrier switching, keep the templates seperate by carrier, switch content by language and then have it cache by theme and language to get optimal performance.

I have made it to the last stage but now I am taking a hammering for the site being 'heavy'.

I am trying to convince my boss that Drupal is an awesome piece of kit, but he doesn't believe me yet.
He uses the custom anap site as an example.

I need to be able to cache the mobile content seperately to the PC content.
And within my mobile content I have 3 different carriers all with different rules for mark up.

 
 

Drupal is a registered trademark of Dries Buytaert.