BaseTheme and Script.Include

Topics: Writing themes
Oct 31, 2011 at 4:52 PM

Hi,

I have created a Theme as a base and another one as a Child theme.

In my child theme in Layout.cshtml

Style.Include("base.css");

And it doesn't find it in the ChildTheme\Styles but finds it in ParentTheme\Styles which is what is expected.

Using

Script.Include("base.js");

It doesn't go down a level, it stays at the Child theme and stays at ChildTheme\Scripts\base.js and then returns a 404, am I missing a step or is there a different way to share scripts?

Sarkie.

Oct 31, 2011 at 5:22 PM

For resources to be found across modules/themes, you need to use a ResourceManifest and then you can have Style.Require("...") instead. See Orchard's jQuery module for an example of how resource manifest works.

Coordinator
Oct 31, 2011 at 5:27 PM

Or you can fully qualify the path to the script from the root of the site. "~/themes/basetheme/scripts/base.js" should work.

Oct 31, 2011 at 5:28 PM

Yup, I've gone for the latter for now, I just assumed it was a bug since it works for sharing Styles between Parent and Child themes, why not Scripts? 

Oct 31, 2011 at 5:34 PM
Sarkie wrote:

Yup, I've gone for the latter for now, I just assumed it was a bug since it works for sharing Styles between Parent and Child themes, why not Scripts? 

Actually that is strange behaviour, I can confirm the same thing.

Jul 15, 2012 at 8:56 AM
Sarkie wrote:

Yup, I've gone for the latter for now, I just assumed it was a bug since it works for sharing Styles between Parent and Child themes, why not Scripts? 

Would be good if all resources would behave the same (so, both css as js files)

Good to find this post though :)

Coordinator
Jul 16, 2012 at 9:39 PM

Do you have a repro where script and css behave differently? If so, please file a bug.