We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    According to this the BlackBerry reports BlackBerry****.

    Are you sure you are doing it correctly?

    What’s the output for the code above? Just make a simple php file on your server and access it with your blackberry test device.
      • 31912 MODX Staff
      • 95 Posts
      I don’t have an actual device at my home office to test on – but using I am using User Agent extension for FireFox to attempt to load in the alternate stylesheet. I did have a user that has a blackberry device earlier to test, just to make sure it wasn’t something with the extension, and it wasn’t working.

      User Agent extension reports: BlackBerry8703e/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/189bool(false) when I have the BlackBerry8703e set – I tried:

      ’BlackBerry’ => ’assets/templates/_style/mobile/bb.css’,
      ’BlackBerry8703e’ => ’assets/templates/_style/mobile/bb.css’,
      ’blackberry’ => ’assets/templates/_style/mobile/bb.css’,

      and it all loads in the default CSS if no devices are found. If I use either my iPhone or User Agent extension set as iPhone it reports:

      Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16bool(false)

      and in both cases it loads up the alternate stylesheet. The same is true for WebOS, SymbianOS + Android devices.

      I just tested out loading the stylesheets in chunks using this plugin: http://modxcms.com/extras/package/557 and it seems to work as expected so maybe I should just switch over to using that method instead...especially now that pages can be cached.

      Thanks for your help!
        • 20413
        • 2,877 Posts
        Try stristr()
        if (stristr($_SERVER['HTTP_USER_AGENT'],$key)) {
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 31912 MODX Staff
          • 95 Posts
          That was it! Thank you so much... I wish I posted here earlier now–it would have saved me hours;p
            • 10076
            • 1,024 Posts
            Okay, all very,very usefull, but I also would like to change the title, to a shorter one. However how to make this into a snippet:
            <?php
            if($browser == 'iphone'){ ?>
              <title>[*pagetitle*]</title>
            <?php }else{ ?>
              <title>[*pagetitle*] [*longtitle*]</title>
            <?php }
            ?>
              • 3749
              • 24,544 Posts
              Quote from: Frank at Jun 10, 2010, 02:44 PM

              Okay, all very usefull, but I also would like to change the title, to a shorter one. However how to make this into a snippet:
              <?php
              if($browser == 'iphone'){ ?>
                <title>[*pagetitle*]</title>
              <?php }else{ ?>
                <title>[*pagetitle*] .' ' .  [*longtitle*]</title>
              <?php }
              ?>


              Use a snippet tag where the title goes and put this in the snippet (I’m assuming Evolution):

              <?php
              
              if($browser == 'iphone'){ 
                $output = '<title>' . $modx->documentObject['pagetitle'] . '</title>';
              }else{
                $output = '<title>' . $modx->documentObject['pagetitle'] . $modx->documentObject['longtitle'] . '</title>';
              }
              
              return $output;
              ?>
              
              


                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 10076
                • 1,024 Posts
                Thanks,

                did not work for me, changed it and tried some bits, here s what does give different title for the Iphone. Called it titleSwap and put a call before the end header tag. Could probably serve symbian too.

                <?php
                $browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
                if ($browser == true){ 
                  $output = '<title>' . $modx->documentObject['pagetitle'] . '</title>';
                }else{
                  $output = '<title>' . $modx->documentObject['pagetitle'] . $modx->documentObject['longtitle'] . '</title>';
                }
                
                return $output;
                ?>


                Else I would like to add stuff like this, any more ideas, I am not a coder, just trying, here s what I would like to add, and maybe get it all in a single snippet (meaning together with all the above)

                <link media="only screen and (max-device-width: 480px)"
                    href="iPhone.css" type="text/css" rel="stylesheet" />
                
                <meta name="viewport" content="width = 320" />
                <meta name="viewport" content="initial-scale=2.3, user-scalable=no" />
                


                One thing , on the Iphone 4 the res will go up I guess, so then what?
                  • 10076
                  • 1,024 Posts
                  Okay, sorted the question that was here. Probably a solution that could poimt to a different stylesheet, but also change a name of a div or an image etc.

                  Here s the snippet, I called it prefixSwapper

                  <?php
                  /* Snippet Title: prefixSwapper, code adapted from Bobyray code  */
                  
                  $output = '';
                  /* array of browser agent names and their respective div prefixes */
                  
                  $prefixArray = array(
                       'iPhone' => 'i_',
                       'SymbianOS/9.1' => 'i_',
                  );
                  
                  /* see if we recognize one */
                  foreach ($prefixArray as $key => $value) {
                      if (strpos($_SERVER['HTTP_USER_AGENT'],$key)) {
                          $output .= $value;
                  
                  
                          break;
                      }
                  }
                  
                  /* if we didn't find one, use the standard DIV name */
                  if ($output == '') {
                      $output = '' ;
                  }
                  
                  return $output;
                  ?>

                  As you can see, the output of this snippet will be "i_" if it detects an Iphone or a Symbian device. If none, it will be empty! Off course you could create more rules with different prefixes for different devices.

                  Create a TV, I called it prefix, assign it to your default template.
                  In default value type:
                  [!prefixSwapper!]


                  Use it like so <div id="[*prefix*]wrapper"> or [*prefix*]style.css or maybe [*prefix*]image.jpg

                  Your CSS file, eg "style.css" would become "i_style.css" or i_image.jpg.
                  Your "wrapper" div would become "i_wrapper".

                  Probably not the best solution, but maybe a start for a "real" snippet?