Site Columns, Page layouts etc not getting deleted on Feature deactivation - sharepoint

I have written a publishing feature which creates some site columns, a content type referring these site columns, a master page and some page layouts.
When I deactivate this feature, the site columns, the master page and the page layouts are not getting deleted from their gallery.
What am I doing wrong here?
Should I be writing an event handler for deleting these files? Shoudnt the deactivation take care of it out of the box?

SharePoint will never remove any artifacts of a type which potentially could cause a user to loose data/changes as part of deactivation of a feature. A user could have used/changed your site column of contenttype and she could have customized the masterpage or page layout.
This non removal is in effect even though the user didn't make any use/change of the artifacts. Which is good because then if you're sure you want to remove them then you can always do it in a feature receiver and don't have to check is SP removed them.

Related

Getting duplicate form while editting item in sp list

One of the user is getting duplicate form (same two form on one page) while editing item in SP2013 list but for other user it is coming fine.
Could anyone suggest me the cause of it.
Check if the form has been customized using InfoPath or SharePoint Designer. If it has, you'll need to examine the form customizations to see what might cause that behavior.
If it has not been customized, try opening the form in a new window and editing the page. There may be duplicate web parts on the page. Audience targeting may be preventing some users (yourself included) from seeing the extra web part.

SharePoint - Find a reference to default.aspx from a site definition

Is there a way from within a feature to locate the default.aspx which is delivered with a custom site definition.
I have a scenario where I replace the default.aspx page with a custom page, but when the feature gets deactivated I need to put the original back in place.
I have considered moving the existing default.aspx to default-old.aspx when the initial replacement happens (activated) however the existing default.aspx doesn't exist yet (when feature executes during provisioning) and hence I do not have the ability to rename the existing.
Hence my question, how can I locate through code the default.aspx page associated with a site definition?
thx
You can use SPWeb.Navigation.Home.Url
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.navigation.spnavigation.home.aspx
I would give your new/updated default page a different name, deploy and then change the welcome page of the site by code in a feature receivers feature activated event. If you are working with Moss 2007 you can use the PublishingWeb.DefaultPage property or for WSS this approach.

How to control order of the tabs in the template selection of SharePoint site creation page?

The New SharePoint Site page has a Template Selection section which can contains multiple tabs. For example, Meetings and Collaboration. These are controlled in webtemp.xml using DisplayCategory. While hiding and unhiding different OOTB templates, I somehow ended up switching the order of the tabs so that Meetings show up first. Can't seem to find any references on how to control the order of the tabs and make Collaboration first again.
Has webtemp.xml been reordered or edited so that Team Site, Blank Site, and Document Workspace are now either below the Meetings sites or are marked as hidden? I captured the output of GetAvailableWebTemplates for a test Team Site and the first 12 templates match the contents and order of an OOTB webtemp.xml. If any of those Collaboration templates are visible in your list, try moving it above the Meeting templates, save, and recycle the app pool.
Is this a Publishing Site? If so, check Site Settings > Page Layout and Site Template Settings to see if any Site Templates are being restricted. From what I can tell in Reflector, the TemplatePicker control calls SPWeb.GetAvailableWebTemplates, which should consistently return OOTB templates first followed by any custom templates. TemplatePicker then loops through the templates and creates a tab each time it encounters a new SPWebTemplate.DisplayCategory.

SharePoint 2007 Publishing site with deep menu structure

I am a beginner in SharePoint and I need to create publishing site that will have multilevel menu. Requirement is that levels will not be fixed and that client should be able to add pages and customize menu.
If I am not mistaken pages can be created only in the first level under the site. I don't see something like folders concept. For the navigation purposes I can add heading and it will be shown as another level. If I need more levels I need to create sub sites.
Site
Page1
Page2
Heading
Page3
Is this correct?
Site
Page1
Page2
Sublevel_1
Page1_1
Sublevel_2
Page2_1
Sublevel_3
Page3_1
...
Can I do something like this without creating SharePoint sub sites ?
If I don't need I will skip writing some custom menu control or write custom SiteMapProvider. I will than need to write UI for managing navigation also.
EDIT:
I have managed to create Folder in Pages list and create (actually move) pages to that folder and even create sub folder but they are not showing on the menu not even in the navigation settings page. I can't approve folder, it is in pending status what ever I try.
I looks like this is not possible by the Andrew Connell: Subfolders are not Supported in the Pages Library in MOSS Publishing Sites
Out of the box, you can modify the navigation for a Publishing site manually.
I assume that you are after a more automated way to do this. Unfortunately, the way to modify the navigation for a PublishingWeb is through the object model and the PublishingWeb.CurrentNavigationNodes object, which would require a timer job or some other method to update as pages are edited/added/deleted.
This is non-trivial and you will still need to create a solution/feature package.
The other way is to create a custom navigation provider.
The issue with both of these options (aside from the actual coding and release) is caching the navigation structure. We have used the standard web cache for the object holding the navigation structure, but using the standard user browsing (i.e. the menu code itself) to kick of a refresh of the navigation is fraught with threading issues.
You can create multiple document libraries in a site and then put the pages in the various libraries. That way you wouldn't need to create sub-sites

Page Layout does not appear in the page layouts list

I have a feature that deploys a few site columns, a content type (inheriting from Page Publishing Content Type) and a page layout based on my content type.
Everything is fine on two tests, performed on different servers, but on the third server, although the feature is being activated correctly and I can see the site columns, content types and the page layout in the galleries, I cannot create a new page based on my page layout because the page layout does not appear in the list of available page layouts.
On all tests I have used the administrator account.
Does anybody have any thoughts on possible reasons for this?
Thanks.
Did you have a look at the "Page layouts and site templates" page under Site Settings? On this page you can enable an option that limits the available page layouts to a specified list of page layouts.
I have worked on a project where we needed to limit the page layouts available on a custom site definition. We implemented this in a feature, that enabled the "limited page layouts" option and populated the list of available page layouts upon activation.
If this is the issue you are having you could simply turn off this option in the web interface or add the new page layouts manually, but you could also consider implementing a feature receiver that automatically adds your custom page layouts to the list of available layouts.
Thank you all for your answers.
What actually happened is that the page layout was, for some reason, deployed as a Master page and not as a Page Layout. The admin has manually changed this and now it works.
This is just an educated guess but check to see if the Page Layout is waiting to be checked-in or approved.
In my case the path for the layout was wrong so the layout itself ended up in a different location, when I corrected that i was able to see the results.
I had added files manually and it did not appear.
When I edited properties of that layout page from UI and saved it, it appeared.

Resources