Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Bootstrap Plugins as Modules?
  • I have a template that I am trying to convert into php and blend it into the FuelPHP and this template uses a lot of plugins and I am not sure how I should set it up to proceed with the rest of the development of the application. 
  • Isn't that front-end stuff? What are you exactly trying to do?
  • It is front-end stuff, but the way they set up their directory is a little nuts. Especially around the assets area. 

    This template has a lot of css files and js files that are specific to each plugins. I'm trying to organize the assets files so I can easily call them when I need to, because it seems to me that the template itself isn't using all of the plugins on every page.

    Here is the link to the template uploaded onto my dropbox account that you can check out and see what I'm talking about. *removed the link*
  • I see your point, that is quite complex, and not really supported (in a structured way).

    If you know the plugin you're about to activate, you know it's name, and therefore the location of it's assets, if you keep them consistent (which you haven't. for css and js they are in a plugins folder, for img they are not).

    So Asset::css('plugins/datatables/datatables.css'); would add the css for the 'datatables' plugin.

    You could make make a bootstrap helper class, so you could do something like

    \Bootstrap::add('datatables', 'ladda', 'pace');

    in your page template (for example), and it would add the requires js and css entries to the asset instance.
  • I agree with you. That was unedited version that I sent to you. I am still trying to organize it to the point where it would be easier to use them. Any ideas how to achieve this?

    I thought about moving all plugins into their own plugin folders such as below

    img/
    js/
    css/
    plugins/
    --- bootstrap/
    -------- bootstrap.css
    -------- bootstrap.js
    --- Messenger
    ------- messenger.css
    ------- messenger.js

    and so on...

    Would that be a far more similar solution for structure and calling purposes?

    Or should I just call them all and let the page figure out if they are going to use it or not? I can see this being a easiest way of doing things, but I would reckon that it would take up a lot of page load time and that is primarily the reason why I don't want to do that and I don't really want to throw anything extra that isn't needed for that specific page. 
  • HarroHarro
    Accepted Answer
    That would be more complex, since you would not be able to use Asset to load those (since that requires the split into img,css and js).

    It would be more logical to use

    img/
    js/
    --- bootstrap/
    -------- bootstrap.js
    --- Messenger
    ------- messenger.js
    css/
    --- bootstrap/
    -------- bootstrap.css
    --- Messenger
    ------- messenger.css

    So you can use

    Asset::js('Messenger/messenger.js);
    Asset::css('Messenger/messenger.css);
  • And to make sure you only load what is needed, i suggested to use an Asset helper class for that.

    This is what we do too, the widgets that are added to the pages of our apps define what css and js they need, and for js, whether they need to be loaded in the header or footer, by adding them to the Asset instance.

    Then when the page renders, the page template has all css and js needed to render that specific page. Not too much, and not too little...

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion