Announcement

Collapse
No announcement yet.

Conditional for Browser detection

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

  • Conditional for Browser detection

    What is the conditional for browser detection? Like if I wanted to display a different image on all browsers except IE (stupid rendering bug).

  • #2
    Have to start at PHP_include_start

    I too had a problem with this. I spent the past three days working on it, and here is the final solution I came up with.


    PHP Code:
    $rt_checkos strpos($_SERVER[HTTP_USER_AGENT], 'MAC_PowerPC');
    if (
    is_int($rt_checkos)){
    $rt_browser 1;

    That gives us a variable which we can check against in a conditional.

    Then we do our conditional...

    PHP Code:
    <if condition="$rt_browser==1">
    This is stuff only a Mac will see...
    </if> 
    Last edited by mcahill; Thu 8 Jan '04, 8:49am.
    Mark Cahill
    Reel-Time, the Internet Journal of Saltwater Fly Fishing
    Allthingscahill.com
    Splitcoaststampers.com

    Comment


    • #3
      You can use vBulletin's is_browser() function...

      is_browser($browser, $version = 0)

      <if condition="is_browser('ie')">Do Internet Explorer Stuff here</if>

      <if condition="is_browser('mac')">Do Macintosh Stuff Here</if>

      The strings it looks for are:
      opera
      ie
      mozilla
      firebird
      camino
      konqueror
      safari
      webtv
      netscape
      mac

      The second parameter is a for the version number so:

      <if condition="is_browser('ie',6)">Do Internet Explorer 6.0 Stuff here</if>
      Translations provided by Google.

      Wayne Luke
      The Rabid Badger - a vBulletin Cloud demonstration site.
      vBulletin 5 API

      Comment


      • #4
        Thats good info wayne, mind if I post that on vBt?

        Comment


        • #5
          Nope.
          Translations provided by Google.

          Wayne Luke
          The Rabid Badger - a vBulletin Cloud demonstration site.
          vBulletin 5 API

          Comment


          • #6
            Rats...

            I tried that for about an hour yesterday...

            I was using MAC_PowerPC though.
            Mark Cahill
            Reel-Time, the Internet Journal of Saltwater Fly Fishing
            Allthingscahill.com
            Splitcoaststampers.com

            Comment


            • #7
              Originally posted by Wayne Luke
              Nope.
              http://www.vbulletintemplates.com/mo...1497#post41497

              Thanks

              Comment


              • #8
                Would anyone mind pointing me in the right direction to create this fix?

                I am having problems with mac and webtv.

                Thanks in advance.

                Comment


                • #9
                  I gather the above code should be placed in a template.

                  Could someone please point me to which templates(s) need to be edited.

                  Thanks in advance.

                  Comment


                  • #10
                    It depends...

                    On what you are trying to do. In my case I was trying to keep my navigation header from showing to MAC users. In that case, you use it in your header template.

                    On what template does the information you want to tailor to the mac and webtv live? That'll be the place for the if statement.
                    Mark Cahill
                    Reel-Time, the Internet Journal of Saltwater Fly Fishing
                    Allthingscahill.com
                    Splitcoaststampers.com

                    Comment


                    • #11
                      Originally posted by babydoll
                      Would anyone mind pointing me in the right direction to create this fix?

                      I am having problems with mac and webtv.

                      Thanks in advance.
                      What fix?
                      Translations provided by Google.

                      Wayne Luke
                      The Rabid Badger - a vBulletin Cloud demonstration site.
                      vBulletin 5 API

                      Comment


                      • #12
                        I have Netscape 4.8 installed to test. I can get it to identify it if I just use netscape, but if I try 4 or 4.8 as the version number, it doesn't work. How can I get it to read if it's an oldie browser?
                        V1 Bad Bunny Emoticons > (For Dark BGs)
                        Squarehead V1 Emoticons -
                        Let Users select postbit style!

                        Comment


                        • #13
                          Anyone could please help me wwwwwith this?
                          V1 Bad Bunny Emoticons > (For Dark BGs)
                          Squarehead V1 Emoticons -
                          Let Users select postbit style!

                          Comment


                          • #14
                            I don't think the version parameter works properly... my IE6 matches here:

                            Code:
                            <if condition="is_browser('ie',5)">Do Internet Explorer 5</if>

                            Comment


                            • #15
                              Maybe this conditional is matching version x or higher? For example, if you check for 4, then 5 and 6 will match?

                              Code:
                              <if condition="is_browser('ie',5)">
                              <if condition="!is_browser('ie',6)">Internet Explorer 5</if>
                              <if condition="is_browser('ie',6)">Internet Explorer 6</if>
                              </if>

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X