Grow your CSS skills. Land your dream job.

Conditional Plugin statement?

  • # June 16, 2012 at 7:02 pm

    I’ve been looking around to see if this was possible and I don’t see much written on the subject. Has anyone ever heard of someone using a method to make plugins conditional to a browser?

    # June 16, 2012 at 9:13 pm

    How about yepnope.

    # June 16, 2012 at 10:22 pm

    Plugins run server side, so JavaScript would be out. You’d have to do UA testing, which… isn’t a good idea. What’s the reason?

    # June 17, 2012 at 12:59 am

    It’s rather lengthly, so bear with me :)

    We’ve got a scenario where we were asked to develop a site that also contained a store locator for a chain that is in a few states. Instead of creating one from scratch we opted to save them some money and use an existing plugin.

    The plugin itself came baked with 3 configurations for detecting your location: none at all (and it just shows all stores), IP address and HTML5 based.

    After the project was launched we noticed the map was just having very unreliable results while trying to use IP address method, which would have hit the most broad user base. So we ended up going with the no autodetect at all based on how the HTML5 method totally misses IE users.

    In order for this option to work properly for visitors, we used an add-on plugin that the authors created that disabled the store locations from showing any locations until AFTER the user put in their zip code.

    Our hope was to make the system dynamic in that we used the proper technology based on your browser / platform. It’s developed for mobile as well, so we wanted to make it dynamically select HTML5 when using supported browsers and mobile, and use the other method in IE.

    So here’s the rub: we modified the hell out of the plugin and it now dynamically selects HTML5 when supported properly EXCEPT the secondary add-on plugin stops any of the listings to show up. Which means even though it knows exactly where I am, it won’t give me results until I again put in my zip code. It’ll see where you are, but it won’t show you what stores are around you. I was looking for some way to dynamically turn that plugin on or off the same way.

    It sounds like I may need to pull what is controlling the store views out of that plugin and apply it directly to the original plugin. I’m just not confident I can get it to work :)

    # June 22, 2012 at 3:00 am

    Just an update on this… what we ended up doing was adding a conditional statement in the plugin itself instead of making the actual entire plugin conditional. If it’s a non HTML5 browser it utilizes the plugin’s filter and when in HTML5 it asks the user to identify their location and display results automatically.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".