We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    I think my original Evo Snippet included in the docs which event(s) to hook it to... there may be several events that are viable for something like this...


    OnLoadWebDocument or OnWebPageInit is probably a good candidate. The way to test it would be to have the Plugin print something then die(); If you see any part of your template on the resulting page, then you would know it fired too late. Make sense?
      • 3749
      • 24,544 Posts
      I’m not sure you would have access to the ID there. I was thinking of OnWebPagePrerender, which fires just before the page is sent to the browser.

      Make sure the page you’re sending them to is published.
        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
        • 19132
        • 199 Posts
        Not getting anywhere with this. I’m too creative with code and the API. It’s my weakness.

        All I want is to just have a simple little plugin that detects if the HTTP_User_Agent (HUA) is mobile. If so, send it to "this" page. From there the CustomCSS can determine which CSS file to load, but frankly I don’t care because I’m going to have the mobile page’ CSS in percentages and to carry out a very narrow function (people log their hours via mobile device).

        I tried to see how BobRay’s CustomCSS determines the HUA but my creative mind simply has its own logic.
          MySQL: 5.0.45
          PHP: 5.2.6
          Linux 2.6.9-023stab048.6-enterprise #1
          cURL enabled
          PDO enabled
          FFox Apple 3.6.8
          Firebug DIS-abled
          • 3749
          • 24,544 Posts
          Quote from: Peter at May 02, 2011, 01:23 PM

          Not getting anywhere with this. I’m too creative with code and the API. It’s my weakness.

          All I want is to just have a simple little plugin that detects if the HTTP_User_Agent (HUA) is mobile. If so, send it to "this" page. From there the CustomCSS can determine which CSS file to load, but frankly I don’t care because I’m going to have the mobile page’ CSS in percentages and to carry out a very narrow function (people log their hours via mobile device).

          I tried to see how BobRay’s CustomCSS determines the HUA but my creative mind simply has its own logic.

          See if this helps. The line in the template uses a snippet tag for the name of the CSS file to load. The snippet checks the HUA and returns the name of the appropriate CSS file, which replaces the tag.
            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
            • 19132
            • 199 Posts
            $browserArray = array(
                 'iPhone' => 'mobile.css',
                 'SymbianOS/9.1' => 'symbian.css',
                 'anotherbrowser' => 'otherbrowser.css',
                 'yetanother browser' => 'stillotherbrowser.css'
            


            That’s right where I get hung up, because I don’t care what HUA it detects; I don’t want nor need to redirect every mobile browser to it’s own page. (I’ll save that for the CustomCSS)

            I just want it to detect that the HUA is a mobile browser and redirect to id 332.

            I really suck at this whole logic thing. I try to be patient with my self but I just find the Evo Plugin documentation to be lacking. I’m missing the Rosetta Stone for Dummies that will help me understand the logic so I can do more stuff with the few sites I manage.

            http://rtfm.modx.com/display/Evo1/Plugins

            Look at this code:
            $url=$this->makeUrl($pg);
            $this->sendRedirect($url, 1);


            And from this link:
            http://rtfm.modx.com/display/Evo1/DocumentParser+Object
            one can find that the
            makeURL
            method has red highlight to indicate "something", failing to describe just what that might be. Deprecated? Useless? Worthless? Really significant?

            And yet that very method is used in the Plugin example in the Documentation. What am I to believe, or do with that? It’s frustrating. Same goes for sendRedirect.
              MySQL: 5.0.45
              PHP: 5.2.6
              Linux 2.6.9-023stab048.6-enterprise #1
              cURL enabled
              PDO enabled
              FFox Apple 3.6.8
              Firebug DIS-abled
              • 3749
              • 24,544 Posts
              I think that red highlight just indicates that it is not a link to another page with more information (though it’s supposed to be a link). For some reason, the non-working links get the "error" class. That method is definitely not deprecated -- MODX itself uses that method a lot.

              That section is just specifying the name of the CSS file for each agent. You can just put one CSS file name for mobile agents and another for any other agent.

              The OP asked about redirecting to a specific page based on the agent. It sounds like you don’t need that (or a plugin). You just need a snippet that checks the HUA and returns the path to the appropriate CSS file and a tag for that snippet where the name of the CSS file goes in the template. It looks like you already have the snippet.
                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