views:

621

answers:

2

I am trying to add a custom css file to my site definition but I am having some issues. I have read that I should place them in 12\TEMPLATE\SiteTemplates\TEMPLATENAME\Layouts\1033\STYLE.CSS But I can't access the file at /_layouts/1033/Styles/STYLE.CSS

Do I need to use a feature to add the STYLE.CSS file? I am for my Site Definition using feature stapling with this element file

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
  <Module Name="CustomMasterPages" Url="_catalogs/masterpage" Path="MasterPages" RootWebOnly="FALSE">
    <File Url="Custom.master"
       Name="Custom.master" Type="GhostableInLibrary" >
      <Property Name="ContentType"
         Value="$Resources:cmscore,contenttype_masterpage_name;" />
    </File>     
  </Module>

</Elements> 

As you can see, I have added the Url: _catalogs/masterpage in the element file, do I need to do something similar for the style file? Thank You

A: 

I'll be honest; I've worked with SharePoint a few months now, but I've never bothered with Feature Stapling

Try something like this:

<Module Name="CssFiles" Url="Style Library/CSS" Path="CSS" RootWebOnly="FALSE">
  <File Url="style.css" Name="style.css" Type="GhostableInLibrary" />
</Module>

... but since this is a Feature, the CSS files should go somewhere in the folder for your Feature. So let's say we name this Feature 'SO.Question' you'd want to put these CSS files in '12\TEMPLATE\FEATURES\SO.Question\CSS'.

Note that the css files need to go in a 'CSS' directory within the feature folder '12\TEMPLATE\FEATURES\SO.Question'. This has to correspond to the Path attribute of the <Module>. If you changed the Path attribute to 'RichardIsAwesome' then you'd put the files in '12\TEMPLATE\FEATURES\SO.Question\RichardIsAwesome'.

LeguRi
Thank you for the help.
unkown
A: 

Look into WSPBuilder; it will give you an easy option to add files to the 12 hive (if you are using Visual Studio). You cannot create a feature that puts files in the _layouts folder. This can only be done by creating a WSP file.

The code you posted will attempt to store the file in _catalogs/masterpage/.. which is 'in the database' and not on the filesystem. (_layouts is in the 12 hive and thus on disk). This is not generally the location to put css files, the location Richard mentioned is, although I prefer to put files shared by all sites in the 12 hive.

Feature stapling is a good way of making changes to the standard site templates.

ArjanP
I am a bit confused now. How should I do if I want to create a Custom Site Definition with a custom master page? I thought that in order to create a custom master page I need to use feature stapling. So my Site Definition is stored in 12 hive while my master page is stored in the database.
unkown
Both of you helped me solving this so thank you, I had to put the files in 12\TEMPLATE\LAYOUTS\1033\STYLES\ instead of 12\TEMPLATE\SiteTemplates\TEMPLATENAME\Layouts\1033
unkown