Closed (fixed)
Project:
AdaptiveTheme
Version:
7.x-3.x-dev
Component:
Theme Settings
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Sep 2012 at 16:37 UTC
Updated:
12 Dec 2012 at 13:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
Jeff Burnz commentedAt this stage I don't know, I need to look into what browsecap can return, I am not entirely sure it can return a group such as "tablets".
Comment #2
mxtThank you Jeff, I've opened a support request in browscap issue queue: http://drupal.org/node/1794072
Comment #3
Jeff Burnz commentedOK, lets postpone this for now based on the outcome of that issue.
Comment #4
mxtOk, we got an answer: https://drupal.org/node/1794072#comment-6524906
Comment #5
Jeff Burnz commentedOK, well I am going to postpone this again because at the moment I don't have the time to craft a feature such as that employed by Mobile Tools - I kind of know how it does it but am not sure this can even run in a theme (maybe, maybe not).
Of course patches are more than welcome and certainly when I get time I can revisit this.
What I would say is that its probably pointless reinventing what Mobile Tools does and we could look at using that as a dependency at getting device groups, such as tablet.
Comment #6
mxtThank you,
ok, I'm going to investigate this: http://drupal.org/project/context_mobile_detect and this: http://mobiledrupal.com/content/using-context-module-mobile-tools-create...
I'll come back here to report potential solutions
Comment #7
mxtOk, I can confirm that the combination:
context + context_mobile_detect
works like a charm!
This allow you to set visibility for regions or blocks based on device groups (mobile, tablet, desktop)
The only issue is that within the same device group, there isn't yet a detection for "isPortrait" or "isLandscape" that definitively would complete the solution.
I've already leaved a request to the php base library: http://code.google.com/p/php-mobile-detect/wiki/Roadmap
Other possible solutions for this lack:
Any other thoughts?
Comment #8
Jeff Burnz commented"isPortrait" or "isLandscape" is actually not a good idea - this would force a page refresh between orientation changes - can you imagine the page suddenly refreshing because you moved a bit while looking at your iPad?
I'll take a look at the mobile detect lib, looks promising.
Comment #9
Jeff Burnz commentedCool, I found this: http://drupal.org/sandbox/matthew.donadio/1780496
I have asked the developer to promote that to a full project, so with that running as a dependency we can have our is_tablet and other conditions and start building some logic around it.
Comment #10
crispinbailey commentedVery cool development. +1
Comment #11
mpdonadioMobile Detect was promoted to full project status: http://drupal.org/project/mobile_detect
Currently dev version only, but will be doing more testing and working towards a proper 1.0 release.
Comment #12
Jeff Burnz commentedAwesome, I'm gonna make this full steam ahead with this feature using Mobile Detect, I think thats great news and something we can really make heavy use of.
Comment #13
mpdonadioJeff, do you plan on working this into your existing framework? I started to look into making a patch for this, but wasn't sure reworking at_get_browser() to return an object/array with the $is_tablet and $is_mobile properties would break things for end users.
I also have an uncomitted patch for http://drupal.org/node/1824042, but am still pondering whether it is a good idea (it's just template_preprocess that sets variables for a few hooks). If this would help you, I can commit/push it.
Comment #14
Jeff Burnz commentedI think that's a way forward, to rework at_get_browser to return an object, aka
$detect = mobile_detect_get_object();Fine, I am totally down with that. I will need to document this in case anyone has actually used at_get_browser().
I'm interested in the performance of mobile detect, as you notice at_get_browser() is cached, can the object be cached, or is this simply not worth it?
The one small issue, which I am sure you identified, is that we need to still set $is_mobile when the user only has Browscap installed. I think I am somewhat keen to see this in at_get_browser() itself, rather than say in template_preprocess() or hook_page_alter() (the two main places at_get_browser is called in AT Core).
So yeah, a patch to re do at_get_browser is the first step, if we can do that now and worry about the rest later (the major refactoring in adaptivetheme_page_alter for example).
Comment #15
Jeff Burnz commentedOn the template_preprocess issue, well, it could be useful, for me its not really important since I would do that anyway, AT Core calls at_get_browser in adaptivetheme_preprocess(), and I can't really stop doing that now, maybe in Drupal 8 I could, but for now I am kind of stuck with that approach. Suggestions welcome of course.
Comment #16
mpdonadioJeff, I have a decent idea for this in my head. It's actually mostly simple, and should help future proof this process a bit. I'll post a patch in the next few days.
Comment #17
mpdonadioFirst pass.
at_get_browser() now returns an associative array.
The thing I am not really sure about is that $is_mobile and $is_tablet are now mixed. TRUE/FALSE if the feature was detected properly, NULL if the feature could not be determined.
It also leaves the Mobile_Detect semantics that $is_mobile will also be TRUE when $is_tablet is TRUE. Not sure what is best here, as both arguments are valid.
Updated the docs in node.tpl.php as a first shot, but let the rest alone.
I think I have it corrected everywhere it needs to be, but I am not terribly familiar with the internals.
I also don't have a working site with Browscap installed right now for regression testing, but I will get to this soon.
Comment #18
Jeff Burnz commentedAgreed, tricky one, I will need to work through the overall logic in the theme and put some thought into it. Great start!
Comment #19
Jeff Burnz commentedOK, I have applied and tested, so we're half way there.
I will rework the Float Region Blocks feature in the theme to use these new options, which means a total re-write of the forms and the logic in hook_page_alter(), as it all gets a lot more complicated. I'm done with the form at this stage and in the next few days will complete the logic that will allow you to unset or move blocks in all mobile devices or just smartphone - which I assume is what we want in this theme - either unset or move blocks in all regions or just smartphone, thus leaving them untouched in tablet, as per the original feature request.
Peeps, I have to add one caveat, I am really fighting for backwards compatibility but it might be a stretch, I can't promise it will be pefectly backwards compatible, but I will try!
Comment #20
mxtThank you guys for working on this.
Just FYI, context_mobile_detect team is working to obtain "isPortrait" and "isLandscape" (see http://drupal.org/node/1796454#comment-6698364)
Comment #21
Jeff Burnz commentedThese few features are in the dev version now, I committed this today. As per usual pull from GIT or wait for the archive to update with todays commits (normally 24 hours from now).
Please see this help page for details, http://adaptivethemes.com/documentation/mobile-regions-and-blocks-changes
Hopefully I will have time to add some screenshots and so on to that help page - there are new setting which, if using Mobile Detect module, allow you to move or hide regions/blocks in either all mobile devices, or just smartphone.
There is a new variable in all templates, for completeness I will mention both variables:
Note that the help page mentions AT 7.x-3.2, which technically has not been released yet (but will be shortly), think of this as the dev version.
If you are using Browscap make sure you are runnint the latest version (7.x-2.0) at this time and be sure to visit the Browscap settings in Drupal to check if the Current browscap data version has been updated (if there is a number there you should be right).