Registering theme-specific assets in a non-packaged theme
Permalink
Hello,
Are there any guidelines or docs on where to register the theme-specific asset files for a non-packaged theme? I've seen a lot of references for packaged themes to register these in the package's on_start method.
But how do we do this in a non-packaged theme?
I'm currently doing it in the beginning of the registerAssets() call before I require the assets to the theme, so that they are available when requiring.
I know there are comments about this in /application/bootstrap/app.php but it does not seem correct to do it there if this is specific for the theme. I'd rather like to do it within the theme to save any other developer from looking through the theme from searching through the hills and lakes for that. Keeping it within the theme keeps it clear for everyone where it is registered at.
It works fine as I'm currently doing it but I'd just like to know if there are any guidelines or standards on how we SHOULD do this? Or is my current approach "allowed"? (although I don't hear any policemen knocking on my door but couldn't think of a better word for now)
Antti / Mainio
Are there any guidelines or docs on where to register the theme-specific asset files for a non-packaged theme? I've seen a lot of references for packaged themes to register these in the package's on_start method.
But how do we do this in a non-packaged theme?
I'm currently doing it in the beginning of the registerAssets() call before I require the assets to the theme, so that they are available when requiring.
I know there are comments about this in /application/bootstrap/app.php but it does not seem correct to do it there if this is specific for the theme. I'd rather like to do it within the theme to save any other developer from looking through the theme from searching through the hills and lakes for that. Keeping it within the theme keeps it clear for everyone where it is registered at.
It works fine as I'm currently doing it but I'd just like to know if there are any guidelines or standards on how we SHOULD do this? Or is my current approach "allowed"? (although I don't hear any policemen knocking on my door but couldn't think of a better word for now)
Antti / Mainio
And by the way, I'm mostly talking about theme-specific JavaScripts that I want to be included in the minifying process. I don't have any problems using the suggested method on how to include the theme-specific CSS/LESS.
You could certainly do it in registerAssets if you really want it to be a part of the theme. In general if we find ourselves registering assets or doing anything that isn't 100% theme related, we put the theme inside its own package and use the package to do the work. If we're not developing a package and we're developing custom code for a site, we'd put it in application/bootstrap/app.php like you said.
OK, thanks for confirming.
Yes, these are definitely theme-specific JavaScripts that would break the theme if not loaded properly. E.g. controlling how the mobile menu works or adding Modernizr to detect touch support (which affects styling on specific elements, e.g. link hovers). Not something "app" specific since without these, the theme would not function properly.
Yes, these are definitely theme-specific JavaScripts that would break the theme if not loaded properly. E.g. controlling how the mobile menu works or adding Modernizr to detect touch support (which affects styling on specific elements, e.g. link hovers). Not something "app" specific since without these, the theme would not function properly.