Announcement

Collapse
No announcement yet.

browser detection

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    browser detection

    Can Miva do web browser detection? It would be helpful. If not, would Toolkit be able to access something that could?
    Colin Puttick
    Miva Web Developer @ Glendale Designs

    #2
    Re: browser detection

    That requires client side scripting, ie javascript.
    Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
    Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
    Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
    Facebook http://www.facebook.com/EmporiumPlus
    Twitter http://twitter.com/emporiumplus

    Comment


      #3
      Re: browser detection

      PHP can. example:
      PHP Code:
      $navigator_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
      $safari = (stristr($navigator_user_agent"safari")>-1) ? 0;
      $ns6 = (stristr($navigator_user_agent"netscape6")>-1) ? 0;
      $ie5 = (stristr($navigator_user_agent"msie")>-1) ? 0;
      $mac = (stristr($navigator_user_agent"mac")>-1) ? 0;
      $windows = (stristr($navigator_user_agent"windows")>-1) ? 0;
      $ns7 = ((stristr($navigator_user_agent"gecko")>-1)  &&  (!$safari)) ? 0;
      $ns4 = ((stristr($navigator_user_agent"mozilla/4")>-1) && (!$ie5)) ? 0
      So why can't Miva?

      I wonder if it's possible to call a PHP script using toolkit and have the PHP script it return the $_SERVER['HTTP_USER_AGENT'] variable string then use Miva if/else with more toolkit to assign variables
      Last edited by dreamingdigital; 08-19-07, 05:41 PM.
      Colin Puttick
      Miva Web Developer @ Glendale Designs

      Comment


        #4
        Re: browser detection

        there is a server variable 's.http_user_agent' that reports the same information. Shouldn't you be able to use IF 'xxxx' CIN s.http_user_agent' ? (Use it in mivascript often).
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #5
          Re: browser detection

          I've never seen s.http_user_agent in any Latu storehelper vars before. I'll give it a whirl tomorrow. I'm feeling doubtful though because it's in mivascript but I've never seen the SMT version.
          Colin Puttick
          Miva Web Developer @ Glendale Designs

          Comment


            #6
            Re: browser detection

            I tried this out recently, but it didn't work for me. (perhaps I was doing something wrong)

            However, it seemed to work fine using Bill's WCW Toolkit V5 to pull the variable out and copy it into an accessible global variable called g.useragent :
            Code:
            <mvt:item name="toolkit" param="vassign|useragent|s.http_user_agent" />
            &mvt:global:useragent;

            Comment


              #7
              Re: browser detection

              try:

              Code:
              &mvt:s:http_user_agent; 
              <mvt:if expr="'mozilla' CIN s.http_user_agent">
              Hey, its Mozilla
              </mvt:if>
              the first line SHOWS the user agent, you need to use the other form when testing the contents of the variable
              Bruce Golub
              Phosphor Media - "Your Success is our Business"

              Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
              phosphormedia.com

              Comment


                #8
                Re: browser detection

                Originally posted by Bruce - PhosphorMedia
                try:
                Code:
                &mvt:s:http_user_agent; 
                <mvt:if expr="'mozilla' CIN s.http_user_agent">
                Hey, its Mozilla
                </mvt:if>
                the first line SHOWS the user agent, you need to use the other form when testing the contents of the variable
                That's really odd... The first line doesn't seem to show anything for me.
                But the testing of the variable appears to work fine.

                I couldn't get it to print the variable when I first tried, too -that's what made me think that the variable was not available via Storemorph. Hence, I tried it with the Toolkit.

                Is it just me, or does the
                Code:
                &mvt:s:http_user_agent;
                not display anything for anyone else?

                Comment


                  #9
                  Re: browser detection

                  Awesome. I love Toolkit. :)

                  This is what I have so far - it's not the greatest but it's simple. I'm sure somebody can make a rock awesome geeked out version.

                  Code:
                  <mvt:comment>*** START Browser & OS Detect ***</mvt:comment>
                  <mvt:item name="toolkit" param="vassign|http_user_agent|s.http_user_agent" />
                  <mvt:item name="toolkit" param="sassign|safari|0" />
                  <mvt:item name="toolkit" param="sassign|ie|0" />
                  <mvt:item name="toolkit" param="sassign|ie7|0" />
                  <mvt:item name="toolkit" param="sassign|ns7_ff|0" />
                  <mvt:item name="toolkit" param="sassign|ns4|0" />
                  <mvt:item name="toolkit" param="sassign|mac|0" />
                  <mvt:item name="toolkit" param="sassign|windows|0" />
                  <mvt:if expr=" 'safari' CIN g.http_user_agent ">
                      <mvt:item name="toolkit" param="sassign|safari|1" />
                  </mvt:if>
                  <mvt:if expr=" 'msie' CIN g.http_user_agent ">
                      <mvt:item name="toolkit" param="sassign|ie|1" />
                  </mvt:if>
                  <mvt:if expr=" 'msie 7' CIN g.http_user_agent ">
                      <mvt:item name="toolkit" param="sassign|ie7|1" />
                  </mvt:if>
                  <mvt:if expr=" 'gecko' CIN g.http_user_agent AND g.safari EQ '0' ">
                      <mvt:item name="toolkit" param="sassign|ns7_ff|1" />
                  </mvt:if>
                  <mvt:if expr=" 'mozilla/4' CIN g.http_user_agent AND g.ie EQ '0' ">
                      <mvt:item name="toolkit" param="sassign|ns4|1" />
                  </mvt:if>
                  <mvt:if expr=" 'windows' CIN g.http_user_agent ">
                      <mvt:item name="toolkit" param="sassign|windows|1" />
                  </mvt:if>
                  <mvt:if expr=" 'mac' CIN g.http_user_agent ">
                      <mvt:item name="toolkit" param="sassign|mac|1" />
                  </mvt:if>
                  <mvt:comment>*** END Browser & OS Detect ***</mvt:comment>
                  
                  <!-- 
                  Echo back Variables for testing 0=false / 1=true
                  Safari: &mvt:global:safari;
                  IE General: &mvt:global:ie;
                  IE 7: &mvt:global:ie7;
                  NS7 / Firefox Family: &mvt:global:ns7_ff;
                  Netscape 4: &mvt:global:ns4;
                  Mac: &mvt:global:mac;
                  Windows: &mvt:global:windows;
                  Complete User Agent String: &mvt:global:http_user_agent;
                  -->
                  PS: I can confirm that &mvt:s:http_user_agent; renders nothing but can be used in an if statement if necessary: <mvt:if expr=" 'windows' CIN s.http_user_agent "> So I'm using the toolkit version since I use a LOT of toolkit everywhere else.
                  Colin Puttick
                  Miva Web Developer @ Glendale Designs

                  Comment


                    #10
                    Re: browser detection

                    What about
                    <mvt:item name="toolkit" param="vassign|agent|http_user_agent" />
                    &mvte:global:agent;
                    Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
                    Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
                    Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
                    Facebook http://www.facebook.com/EmporiumPlus
                    Twitter http://twitter.com/emporiumplus

                    Comment


                      #11
                      Re: browser detection

                      This is way cool because now I can load up different javascript source files depending on what the customer is using. This is giong to save bandwidth and load times. Woohoo!
                      Colin Puttick
                      Miva Web Developer @ Glendale Designs

                      Comment

                      Working...
                      X