Open joshribakoff opened 11 years ago
Here's the solution - not sure if it works with Magento's XML. Basically you do the checking if its already loaded in JS (not PHP checking the XML). This makes sure that it doesn't load it in our module even if someone hard coded it into a template, or didn't call it "jquery.js", etc.
http://stackoverflow.com/questions/7102786/is-it-bad-to-add-jquery-multiple-times-on-a-page
As for the base path, there's a Magento, ZF, or $_SERVER way of checking what the request URI was, and using dirname() to get the base path (that's if ZF's function doesn't work with Magento, or Magento doesn't provide the base path which I think it should)
Either use layout.xml, or prefix the path with logic to get the base path if running Magento in a sub-directory.
I kind of prefer the latter, because other Magento extensions install jQuery... when users get two jqueries on the page it resets previously loaded plugins. Should research to see how other extensions solve this (probably they don't) - but one idea would be loop through all the layout XML nodes & pattern match it for the string "jquery" and only add it if its not found, that could be a huge performance hit. So another option would just be a setting for the user to toggle if things don't look right - problem there is our extension loads prior to the conflicting extension, it would be the conflicting extension that needs it's jquery disabled - responsibility would be on the conflicting extension to not include duplicate jquery, but if the user installed that extension before ours they will invariably blame us, so a solution would be nice here.