Browser agent detection causing site to break

Discussion in 'Templates customization' started by lipulse, May 5, 2010.

  1. lipulse

    lipulse New Member

    Joined:
    May 18, 2009
    Messages:
    2
    We are attempting to do browser agent detection to utilize a different stylesheet if the device is an iPhone. Here is the code we're using inside of the head tag:
    Code:
    <!--#if expr="(${HTTP_USER_AGENT} = /iPhone/)"-->  
     
    <!-- 
        <link rel="stylesheet" type="text/css" 
            href="{$config.root_surl}/templates/css/mobile.css" />
     
    -->  
    
    <!--#else -->  
       
    <!-- 
        <link rel="stylesheet" type="text/css" 
            href="{$config.root_surl}/templates/css/reset.css" />
        <link rel="stylesheet" type="text/css" 
            href="{$config.root_surl}/templates/css/amember.css" />
        <link rel="stylesheet" type="text/css" 
            href="{$config.root_surl}/templates/css/site.css" />
    
    -->  
    <!--#endif -->  
    
    
    However, this code generates this error code:

    Fatal error: Smarty error: [in header.html line 7]: syntax error: unrecognized tag 'HTTP_USER_AGENT' (Smarty_Compiler.class.php, line 551) in /home/lipulse/public_html/subscribe/smarty/Smarty.class.php on line 1102


    Any suggestions?
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Try to change first line to:
    Code:
    {literal}
    <!--#if expr="(${HTTP_USER_AGENT} = /iPhone/)"-->  
    {/literal}
    
    Let me know if this will not help.
  3. lipulse

    lipulse New Member

    Joined:
    May 18, 2009
    Messages:
    2
    Tried it and it gets rid of the error, however, the css isn't picked up for any browser now. I have used this code successfully in staight HTML.
  4. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    Here is another idea I had. Have a blank registration page that is nothing more than a redirector and text on it if it doesn't work. Redirect the page to the mobile_login.htm if it's mobile and to the standard login.htm if it isn't.

    This is a real problem. I just realized it now after investing all this time, although many mobile browsers can display the full page.

Share This Page