Skip to content
General Revolution Evolution Add-ons International
Login | Register | MODX.com
MODX Open Source Content Management System, Framework, Platform and More.
Find a Partner | Hosts + SaaS | Jobs | Donate
  • RegisterSign Up with the MODX Community
  • LoginUse Your MODX.com Account
  • MODX Community Forums
  • Add-ons
  • Templates
  •  
  • Changing Templates Based On User Agent#

  • 23571
    219
    greg smart | developer
    my twitter | my blog | my company

    Pleth Reply #1, 11 months, 4 weeks ago

    Reply
    • Link to this post#1
    I should note that this is on revo 2.1

    Using this plugin:

    https://github.com/jkenters/modMobile

    (pastebin version of the main plugin page)

    http://pastebin.com/Qxz43Z5k


    The plugin detects the useragent, then uses $modx->resource->set('template',

    to set the mobile template.



    The event the plugin was tied to was "onLoadWebDocument"

    The problem appeared to be that this was getting cached, so if you clear the cache, visit the site with a mobile user agent, it gets set, but then if you visit with a desktop user agent, it is still set to mobile.

    I added the event "onLoadWebPageCache" as well, but it doesn't seem to fix the caching problem.

    This still happens even if all caching is disabled.

    Is this the wrong use of $modx-resource->set('template , is there something else we should be using instead?


  • 22303
    9,765
    - MODX Chief Architect

    Jason Coward | MODX Chief Architect

    jasoncoward.com | @drumshaman

    opengeek Reply #2, 11 months, 4 weeks ago

    Reply
    • Link to this post#2
    If the Resource is cacheable, you cannot change the Template. It will only be processed by the first request anyway. Make the Resource non-cacheable if you want to dynamically change the Template. This worked before because of a bug fixed for 2.1 that was reprocessing the Template even when cached.


  • 24068
    4

    pureppl Reply #3, 11 months, 4 weeks ago

    Reply
    • Link to this post#3
    Hello,

    even if modMobile would work, there is still no way for the user to switch to the normal presentation of the website.

    So yes, you should use something else. I cant realy tell what "something else" exactly is, as i'm also trying to figure out what the best way is to switch to handheld-layouts.


  • 32316
    322

    whistlemaker Reply #4, 11 months, 2 weeks ago

    Reply
    • Link to this post#4
    I'm looking at this approach:
    http://www.alistapart.com/articles/responsive-web-design/
    So not switching html templates - just using css that alters presentation based on the browser window width.


  • 24068
    4

    pureppl Reply #5, 11 months, 2 weeks ago

    Reply
    • Link to this post#5
    Thank you, interesting link.

    The "Only with CSS" way is a route i would like to go.
    And i think it is the way we are all should go.
    But will the browsers let us?


  • 23571
    219
    greg smart | developer
    my twitter | my blog | my company

    Pleth Reply #6, 11 months, 2 weeks ago

    Reply
    • Link to this post#6
    We have been looking at http://lessframework.com/, seems like a pretty good approach. Definitely better than making separate templates for different devices.


  • 1169
    302
    DEVELOPMENT ENV:- MODx Revolution 2.0.8  WAMP 2i Apache 2.2.1 Php 5.3 Mysql 5.1.36 MySQL client version: mysqlnd 5.0.5-dev

    allanb Reply #7, 11 months, 1 week ago

    Reply
    • Link to this post#7
    I have used less.js for a template to change the color scheme it worked very well for that. It generated the colors needed from one system variable I added to the manager. I could see it working using a variable from the screen size.
    Good luck with your implementation. You can see how I went about it in my signature if you are interested.


  • 24068
    4

    pureppl Reply #8, 11 months, 1 week ago

    Reply
    • Link to this post#8
    Quote from: pleth at Jun 10, 2011, 07:16 PM
    We have been looking at http://lessframework.com/, seems like a pretty good approach. Definitely better than making separate templates for different devices.

    Thanks for that link, it did put me on the right track.





Actions

Login to Post

Other Support Options

To file a bug or make a feature request visit our issue tracker, or you can also purchase commercial support.

Love MODX?

If you build sites for a living with MODX or just love using it, why not give back?

Information

Posted in this thread:
allanb, opengeek, pleth, pureppl, whistlemaker

 
Back to Top

MODX Global HQ

1333 N Stemmons Fwy, Ste 110
Dallas, TX 75207
United States

+1 (469) 777-MODX (6639)

The MODX Company

  • Contact
  • Media Center
  • Careers at MODX
  • Wall of Fame
  • The MODX Blog

Sponsors

SoftLayer Firehost: Secure Cloud Hosting

Stay Connected

Read our previous email newsletters.

Twitter Facebook Google+ LinkedIn github Feeds

Privacy Policy | Terms of Service | Pixels by AKTA Web Studio© 2005-2012 MODX. All rights reserved. Trademark Policy