Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Conditional Assets best practices
  • Just started using Fuel and really <3'ing it. Wow! Anyways... I'm extending off the base template controller and I want to load different js/css assets into my template depending on the action. I tried creating an asset group in the conroller's action then I added Asset::render('css_top') in my template's view but it doesn't work. Am I missing something here? Should I be assigning the rendered css to $this->template->css_top or something? Anyways, I won't attempt to make any more assertions as to how this should be done. I'll just let you wonderful, helpful people tell me what's up! Thanks in advance.
  • haha tried this and it didn't work... $content = array(
    "css_top" => array('main.css','features.css'),
    "yield" => View::factory('home/index')
    );
    $this->template->content = $content;
  • Hey, for example in extended controller, I do smth like this:
            \Asset::css(array(
                             'style.css',
                             'jquery.fancybox.css'
                        ), array(), 'main', false);
    

    so I have this CSS files all over the place. And later, if I want add some specific 'css' file in controolerX, I do this in before() method:
    \Asset::css(array('uploadify.css'), array(), 'main', false);
    

    Thants all
  • I also forget to mentions, there is a more advanced, asset package for fuel already, take a look here; http://fuelphp.com/forums/topics/view/2187
  • Or you can use a more complex/powerful asset package like "Assetic" : https://github.com/fuel/assetic

Howdy, Stranger!

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

In this Discussion