2

I have a problem when I activate the feature on the subsite. I try to create a wsp package with the module and feature. In the module I have stp files (list templates).

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Module Name="Module_Template" Url="_catalogs/lt">
        <File Path="Module_Template\Stp\myTemplate1.stp" Url="myTemplate1.stp" Type="GhostableInLibrary" IgnoreIfAlreadyExists="True">
            <Property Name="LanguageDisplay" Value="1033" />
        </File>
        <File Path="Module_Template\Stp\myTemplate2.stp" Url="myTemplate2.stp" Type="GhostableInLibrary" IgnoreIfAlreadyExists="True">
            <Property Name="LanguageDisplay" Value="1033" />
        </File>
    </Module>
</Elements>

There is my Feature.xml

  <Feature xmlns="http://schemas.microsoft.com/sharepoint/" Title="MyFeature Install Modules" Id="1c68d642-89ad-49ee-bfe1-38aac06272ee" ReceiverAssembly="MyFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1fea90db2a1bbfe5" ReceiverClass="MyFeature.Features.Feature1.Feature1EventReceiver" Scope="Web">
      <ElementManifests>
        <ElementManifest Location="Module_Template\Elements.xml" />
        <ElementFile Location="Module_Template\Stp\myTemplate1.stp" />
        <ElementFile Location="Module_Template\Stp\myTemplate2.stp" />
      </ElementManifests>
    </Feature>

If I activate my feature on WebRootSite the files from module copy to List Templates correct. But if I activate the feature on subsite i get an exception:

threw an exception during activation: Failed to instantiate file "myTemplate1.stp" from module "Module_Template": The specified list does not exist.

If I add the property (to Module) RootWebOnly="True" there is no exception but the files do not copy to the List Templates on the server. What im doing wrong?

3

List template gallery (the url atribute of _catalogs/lt) is only available in the root web of the site collection. So you get an exception when the feature is activated in the subsite because it cannot find the specified list (http://sitename/subsitename/_catalogs/lt). The templates should be available across the site collection.

Change the feature scope to site and deploy again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy