Register Assets (.js and .css) for a single page inside your controller file?

Permalink
I'd like to register/load .js and .css files only for my single pages so as not to load these plugins for the entire site. I see how it's done in the /themes/myTheme/page_themes.php dir but how would one make this happen in the controller for a single page. "addHeaderItem" is now bad practice. I have my javascript inside of "../applications/js" and my css in "../applications/css"
Would like to create an alias (where would that be done) and register them in the controller much like:
public function registerAssets() {
        $this->registerAsset('css', 'video-js');
        $this->registerAsset('javascript', 'video');
   }


Would appreciate any help.

Thanks

binomonkey
View Replies:
nicolaikr replied on at Permalink Reply
Hi Bjorn,

I just had the same "problem".
I ended up adding the lines
$this->register(...);

In the
view()
method. It seems to work.

I can't say if it is best practise, but it worked for me :)

Regards,
Nicolai