Return to Snippet

Revision: 55525
at February 10, 2012 05:14 by rumremix


Updated Code
<!-- ### Example edits to elements.xml ### -->
<!--Here is an example of an edited file for a master page...-->

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="masterpagecatalog"  Url="_catalogs/masterpage"  RootWebOnly="TRUE">
  <File Path="masterpagecatalog\LLC.master" Url="LLC.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
    <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    <Property Name="UIVersion" Value="4" />
    <Property Name="ContentTypeId" Value="0x010105" />
    <Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;" />
    <Property Name="MasterPageDescription" Value="Masterpage for Learning Center." />
  </File>
</Module>
</Elements>

<!--And here is an example of an edited file that places files into three different subfolders within the Style Library...-->

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="StyleLibrary" Url="Style Library"  RootWebOnly="TRUE">
    <File Path="StyleLibrary\lilly_main.css" Url="Lilly/lilly_main.css"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\lessons.js" Url="Scripts/lessons.js"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\banner-outlook-rm.jpg" Url="Lilly/images/banner-outlook-rm.jpg"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\bg-persChoiceBottom.jpg" Url="Lilly/images/bg-persChoiceBottom.jpg"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\bg-persChoiceMid.jpg" Url="Lilly/images/bg-persChoiceMid.jpg"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\bg-persChoiceTop.jpg" Url="Lilly/images/bg-persChoiceTop.jpg"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\new-window.png" Url="Lilly/images/new-window.png"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
  </Module>
 
</Elements>

Revision: 55524
at February 10, 2012 04:50 by rumremix


Initial Code
<!--Here is an example of an edited file for a master page...-->

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="masterpagecatalog"  Url="_catalogs/masterpage"  RootWebOnly="TRUE">
  <File Path="masterpagecatalog\LLC.master" Url="LLC.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
    <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    <Property Name="UIVersion" Value="4" />
    <Property Name="ContentTypeId" Value="0x010105" />
    <Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;" />
    <Property Name="MasterPageDescription" Value="Masterpage for Learning Center." />
  </File>
</Module>
</Elements>

<!--And here is an example of an edited file that places files into three different subfolders within the Style Library...-->

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="StyleLibrary" Url="Style Library"  RootWebOnly="TRUE">
    <File Path="StyleLibrary\lilly_main.css" Url="Lilly/lilly_main.css"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\lessons.js" Url="Scripts/lessons.js"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\banner-outlook-rm.jpg" Url="Lilly/images/banner-outlook-rm.jpg"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\bg-persChoiceBottom.jpg" Url="Lilly/images/bg-persChoiceBottom.jpg"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\bg-persChoiceMid.jpg" Url="Lilly/images/bg-persChoiceMid.jpg"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\bg-persChoiceTop.jpg" Url="Lilly/images/bg-persChoiceTop.jpg"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
    <File Path="StyleLibrary\new-window.png" Url="Lilly/images/new-window.png"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"  >
      <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
    </File>
  </Module>
 
</Elements>

Initial URL

                                

Initial Description
<strong>Setting up a sp .net soln</strong> 

<p>File --&gt; New --&gt; Project</p>
<p>on lefthand side -&gt; Sharepoint -&gt; 2010</p>
<p>usually select an empty template</p>
<p>name the project</p>
<p></p>
<p>to add files, create a module...</p>
<p>right-click project --&gt; add --&gt; new item</p>
<p>select "module"</p>
<p>give the module a name (such as masterpagecatalog)</p>
<p>this will create the module, containing an elements.xml file and open the elements.xml file in code editor. Sample.txt will also be created but may be deleted.</p>

<p>Drag any previously created files that will live in the new module into the module icon in solution explorer</p>

<p>Edit elements.xml.  (See example edits to elements.xml in code block further down.) </p>


<p>Edits to make to default xml:</p>

<p>in &lt;Module&gt; tag, put a url (such as  Url="_catalogs/masterpage" ) and put  RootWebOnly="TRUE"</p>

<p>The &lt;file&gt; tag will also be created with a default url property. Make sure to edit this so that it is correct. By default, it will create a path starting with the name of the module. And if there is no such folder already with that name beneath the Module path, the feature will create one.  The actual path is designated by both the &lt;module&gt; url property and the &lt;file&gt; url property (that is, both of those properties are combined).</p>

<p>Add Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" to the &lt;file&gt; elements. IgnoreIfAlreadyExists="TRUE" means "overwrite existing file". Type="GhostableInLibrary" setting is used when a file is placed into a library. If a file is placed outside of a library, Type="Ghostable" would be used.</p>

<p>Change the &lt;file&gt; tags so that it is not self-closing.</p>

<p>Add some Property tags.Columns in the master page correspond to file object properties indicated in the module xml. Other file properties in the xml will also be added to the "property bag" that do not correspond to master page columns (see &lt;property&gt; tags above). </p>

<p>First, it is good practice to always add
&lt;Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/&gt;</p>

<p>On compliation, Value="$SharePoint.Feature.Id$" will be replaced with guid of feature. </p>

<p>For a master page, the following metadata will be added via the property tags</p>

<p>&lt;Property Name="UIVersion" Value="4" /&gt; </p> 
<p>&lt;Property Name="ContentTypeId" Value="0x010105" /&gt;</p>
<p>&lt;Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;" /&gt;</p>
<p>&lt;Property Name="MasterPageDescription" Value="Masterpage for SepulvedaPOC sites." /&gt; </p>


<p>Make sure to edit the description as appropriate.</p>

<p>When the module was created, VS automatically created a feature called "Feature 1". Note that features may also be created by right-clicking "Features" in soln explorer and selecting "Add Feature".</p>

<p>Next step: add event reciever feature activated code if necessary</p>

<p>* Make sure to add the proper modules to the feature<br>
* Make sure that Scope is set to "Site" in the feature if the solution is a sandbox solution</p>

Initial Title
Setting up Sharepoint files as a visual studio .Net solution

Initial Tags
Net, sharepoint

Initial Language
XML