gantry / gantry5

:rocket: Next Generation Template / Theme Framework
http://gantry.org
1.04k stars 204 forks source link

Create atom to load jQuery/Mootools etc from Joomla #1057

Closed DanGthatRokGallery closed 8 years ago

DanGthatRokGallery commented 8 years ago

In this Topic http://www.rockettheme.com/forum/gantry5-for-joomla/245967-not-loading-css-or-js two separate users have the issue that when the Default Home item menutype is set to Gantry 5 -> Custom Page the CSS and JS for NoNumbers doesn't load.

mahagr commented 8 years ago

This is not a bug in Gantry as Gantry themes are not using Bootstrap 2. Joomla has a method to load Bootstrap 2 framework. All extensions which use Bootstrap should call

JHtml::_('boostrap.framework');

to make sure that Bootstrap has been loaded.

That said, I can make atom that loads Bootstrap when inserted to the page...

@w00fz What do you think?

w00fz commented 8 years ago

@mahagr Have you checked the NoNumber code? If the plugin is not calling the bootstrap.framework behavior, then it's the plugin's fault, if it is then it's something on our end.

I think an Atom specific for Joomla, with a set of common toggles to load jQuery, MooTools, Bootstrap (CSS and JS) is a good thing to have but the bottom line is it should be the extension triggering the use of whatever behaviors it needs (like happened with joomla/joomla-cms/issues/6821) and if they do but somehow it conflicts or doesn't work with Gantry, we need to fix it.

mahagr commented 8 years ago

I haven't checked NoNumber code, but its the same issue as with Joomla.

I will create atom that loads Bootstrap and other frameworks as needed; we could do something similar for WP (and Grav) as well.

JoomFX commented 8 years ago

@w00fz @mahagr guys, it's a bit offtopic but anyway...

I'm currently loading jQuery with the following:

{{ joomla.html('jquery.framework') }}

The above is a Joomla specific code and I'm planning to convert all my G5 templates to Grav in the near future.

So, I was wondering... what do you think about the idea to include jQuery in G5, in the framework itelf, in the assets folder where we have the html5shiv-printshiv.min.js for example. And then to create a Twig syntax to call this jQuery, for example:

{{ gantry('jquery.framework') }}

Hmm, while I'm writing this I realize that this might not be a good idea, mostly because jQuery might be loaded twice - once from Joomla and once from G5. Also, there is another downside - you will need to keep an eye on jQuery and update it whenever a new version is released.

Anyway, if you can figure out how to load jQuery only once, even if a particular page is calling both Joomla's jQuery and G5's jQuery and if you think the above might be beneficial, than I'll be really happy to see this implemented. If not, I'll find my way in Grav as well ;)

mahagr commented 8 years ago

Purpose of this atom would be to prevent us from loading jquery/mootools.. more than once by using the one from the underlying platform. The downside is that we need to create atom per platform as jQuery already exists in Grav, Joomla and WP, but it gets called in a very different way in each of them.

The purpose of this issue is really fix "bad" Joomla extensions that assume too much, but this atom could also be used as workaround on using jquery, bootstrap etc in particles -- I understand what you're trying to accomplish here.

That said, I do not think that we should start shipping jQuery or Boostrap in Gantry as Gantry itself doesn't use either of them. But because of jQuery does happen to be in all 3 platforms, it might be a good idea to provide unique API to load it; as long as its supported by underlying platform.

I'll look into it.

JoomFX commented 8 years ago

Thanks Matias!

Yes, "unique API to load it" is exactly what I was trying to say :smile:

It will be great if there is a unique Twig syntax (API) that once called, will check the platform you are on and will then load the jQuery that comes with the platform. That's how we would be able to develop fully platform independent particles. Without this "unique API to load jQuery" we will need to modify the particles for each platform and the developer will have 3 different versions of a particle instead of 1 that will work out of the box on all platforms ;)

Anyway, it really isn't something urgent. Thank you for looking into it ;)

mahagr commented 8 years ago

@JoomFX Can you create new issue for the API part; I just added the missing Atom this time.

kat05 commented 8 years ago

Just a note, the original issue mentioned by @DanGthatRokGallery has been addressed by @mahagr today in latest CI.