I have a master page deployed with a feature which has custom javascript and css references on it. I am using the <Sharepoint:ScriptLink>
and <Sharepoint:CssLink>
tags and the code is deployed into the Style Library collection. Here are the exact tags:
<SharePoint:ScriptLink ID = "jquery152" Language="javascript" Name="~sitecollection/Style Library/AcmeCompany/js/jquery-1.5.2.min.js" runat="server" />
<SharePoint:ScriptLink ID="cyclePlugin" Language="javascript" Name="~sitecollection/Style Library/AcmeCompany/js/jquery.cycle.min.js" runat="server" />
<SharePoint:ScriptLink ID="dartTheme" Language="javascript" Name="~sitecollection/Style Library/Dart/js/DartIntranetTheme.js" runat="server" />
When the feature is deployed I am using the ChildSiteInit function to also declare that all child sites should use these same files. The following is the code I am using to activate this for child sites:
public class ChildSiteInit : SPWebEventReceiver
{
/// <summary>
/// A site was provisioned.
/// </summary>
public override void WebProvisioned(SPWebEventProperties properties)
{
//base.WebProvisioned(properties);
SPWeb childSite = properties.Web;
SPWeb topSite = childSite.Site.RootWeb;
childSite.MasterUrl = topSite.MasterUrl;
childSite.CustomMasterUrl = topSite.CustomMasterUrl;
childSite.AlternateCssUrl = topSite.AlternateCssUrl;
childSite.SiteLogoUrl = topSite.SiteLogoUrl;
childSite.ApplyTheme("AcmeCoIntranet");
childSite.Update();
}
}
This works great for the root site and the master page with javascript and css are working as expected. However, when I create a child site the javascript and css are broken.
Does anyone know how to get the child sites to also see the root css and js files? I have put them in the Style Library collection but maybe they need to go in the global _layouts folder...? I'm using SharePoint Foundation 2010.