Ghostable vs. GhostableInLibrary – A Lesson on Custom Form Deployment in SharePoint
December 15, 2009 2 Comments
When provisioning files, you have the option to set files as either Ghostable, GhostableInLibrary, or, to not set that value, and keep it unghosted. All that means is can the file be cached at the web front end level, or, is it always served and built from the database. Ayman El-Hattab has a good write-up on this over at his blog here: http://www.sharepoint4arabs.com/AymanElHattab/Lists/Posts/Post.aspx?ID=97
However, what we want to know is how is the file treated during deployment for custom forms?
Let’s take for instance, you’ve created some custom list forms, and need to deploy those out to a site. Let’s call our file CustomForm1.aspx, and let’s tuck this away in a List Instance feature.
feature.xml
1: <Feature xmlns="http://schemas.microsoft.com/sharepoint/"
2: Id="{6A88A1A8-69A9-4bbb-8580-3FBA31B2DF66}"
3: Title="GhostableVsGhostableInLibrary"
4: Description="Ghostable vs. GhostableInLibrary Demonstration Code"
5: Scope="Web"
6: Hidden="false"
7: Version="1.0.0.0"
8: Creator="Grace-Hunt, LLC. | www.grace-hunt.com"
9: >
10: <ElementManifests>
11: <ElementManifest Location="manifest.xml"/>
12: <ElementFile Location="CustomForm1.aspx" />
13: </ElementManifests>
14: </Feature>
manifest.xml
1: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
2: <ListInstance FeatureId="{9749B227-36E3-4564-96FC-E75BA895BD74}"
3: Id="e7a36212-b396-4495-aaf9-be414fbd27df"
4: TemplateType="10306"
5: Title="CustomList"
6: Url="Lists/CustomList"
7: OnQuickLaunch="TRUE"
8: Description="Ghostable Vs. GhostableInLibrary Test"/>
9: <Module Name="CustomForm" Url="Lists/CustomList/CustomForms">
10: <File Path="CustomForm1.aspx" Url="CustomForm1.aspx" Type="GhostableInLibrary"/>
11: </Module>
12: </Elements>
Let’s deploy this as “GhostableInLibrary” first, and see what happens…
Look at that, we have a list created from a custom list definition, which is not inheriting from a Document Library, however, if we deploy the form to our list as GhostableInLibrary, we see that the list item count goes up by 1, and, if we view the list contents, there is nothing there. This is obviously not what we want to do!
Now if we re-deploy this as just Ghostable, the list item count stays the same, and we have no “ghost” item in our list, and our custom forms have been properly deployed.
manifest.xml
1: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
2: <ListInstance FeatureId="{9749B227-36E3-4564-96FC-E75BA895BD74}"
3: Id="e7a36212-b396-4495-aaf9-be414fbd27df"
4: TemplateType="10306"
5: Title="CustomList2"
6: Url="Lists/CustomList2"
7: OnQuickLaunch="TRUE"
8: Description="Ghostable Vs. GhostableInLibrary Test"/>
9: <Module Name="CustomForm" Url="Lists/CustomList2/CustomForms">
10: <File Path="CustomForm1.aspx" Url="CustomForm1.aspx" Type="Ghostable"/>
11: </Module>
12:
13: </Elements>
So, with that, I leave you with the lesson learned here – if you need to deploy custom forms to a regular SharePoint list, deploy them as Ghostable, not GhostableInLibrary, otherwise you end up with that “ghost” item in the list.
Very useful post.
Thank you!
nice I was looking for an example. Now its even more clear.