Kentico CMS 7.0 Developer's Guide

CSS stylesheets and sites

CSS stylesheets and sites

Previous topic Next topic Mail us feedback on this topic!  

CSS stylesheets and sites

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example assigns a CSS stylesheet to a site.

 

private bool AddCssStylesheetToSite()
{
  // Get the css stylesheet
  CssStylesheetInfo stylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewStylesheet");
  if (stylesheet != null)
   {
      int stylesheetId = stylesheet.StylesheetID;
      int siteId = CMSContext.CurrentSiteID;

 
      // Save the binding
      CssStylesheetSiteInfoProvider.AddCssStylesheetToSite(stylesheetId, siteId);

 
      return true;
   }

 
  return false;
}

 

The following example removes a stylesheet from a site.

 

private bool RemoveCssStylesheetFromSite()
{
  // Get the css stylesheet
  CssStylesheetInfo removeStylesheet = CssStylesheetInfoProvider.GetCssStylesheetInfo("MyNewStylesheet");
  if (removeStylesheet != null)
   {
      int siteId = CMSContext.CurrentSiteID;

 
      // Get the binding
      CssStylesheetSiteInfo stylesheetSite = CssStylesheetSiteInfoProvider.GetCssStylesheetSiteInfo(removeStylesheet.StylesheetID, siteId);

 
      // Delete the binding
      CssStylesheetSiteInfoProvider.DeleteCssStylesheetSiteInfo(stylesheetSite);

 
      return true;
   }

 
  return false;
}