Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to set the "Hidden" attribute for a listtemplate to hide it from the create list dialog. I need a solution where I can switch visibility of listtemplates on a per web basis. First I tried this:

$web.ListTemplates["Project Document Library"].Hidden = $true

Unfortunately the "Hidden" attribute is readonly. According to MSDN the attribute is defined in the SchemaXml attribute of the listtemplate. So I tried this:

$template=$web.ListTemplates["Project Document Library"]
[xml]$schema=$template.SchemaXml
$schema.ListTemplate.SetAttribute("Hidden", "TRUE")
$template.SchemaXml=$schema

Found out that SchemaXml is readonly as well.

Thank you for every hint about how to hide listtemplates...

Regards, Friedrich

share|improve this question

1 Answer 1

The suggestion above, although acheiving the desired effect will need to be done on all servers in the farm and is unlikely to survive an upgrade / patch. It's not therefore generally a good idea to do this.

Using PowerShell - If you grab the ID of the list template feature

$myWeb = (Get-SPSite "http://MySite").OpenWeb()
$featureToDisable = Get-SPFeature -Web $myWeb | ?{$_.DisplayName -eq "DocumentLibrary"}

Check that you have only one element in $featureToDisable. Now, you will have the Identity of the list feature that although installed at farm level has a scope of Web. This can now be disabled ...

$featureToDisable | Disable-SPFeature -Url $myWeb.Url

If you want it to be enabled, then you will have to get a reference to the feature at the farm level and then pipe this to the Enable-SPFeature commandlet with similar parameters. e.g.

$featureToEnable = Get-SPFeature | ?{$_.DisplayName -eq "DocumentLibrary"}
$featureToEnable | Enable-SPFeature -Url $myWeb.Url
share|improve this answer
    
I am going to delete my answer as yours is far superior for the reasons you mention. You might want to update the first few lines of your post. –  Robert Kaucher Apr 24 '13 at 17:34
    
I'm curious to know if disabling the 'DocumentLibrary' feature could have any surprise consequences. I'm also curious to know what Robert Kaucher's deleted answer was, as it might still have provided some valuable insight even if it is supposedly an inferior answer. –  Dennis George Oct 23 '13 at 21:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.