I have a custom MOSS publishing site collection / sites which have been provisioned with the following site definition properties within ONET.XML.
<Properties xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Key="SimplePublishing" Value="false"/>
...
<Property Key="VersioningOnDocuments" Value="Major"/>
</Properties>
Is it possible to access/update these properties through the API such that, for example, all newly created document libraries have major/minor versions?
I'd like to do something like this:
PublishingWeb.Properties["VersioningOnDocuments"] = VersioningSettings.MajorAndMinor;
I haven't had any luck so far determining where these properties are stored.
Thanks.
The properties that you see like <Property Key="VersioningOnDocuments" Value="Major"/> are used by the feature or Provisioning Engine at the time of creation of the Site.
The only way to change them is to edit the onet.xml and you are forbidden to do so if it is a Out of the Box Onet.xml that came along the SharePoint Installation.
To Solve your requirement you can take this way
Make a copy of the Custom Site Definition and Edit the onet.xml of the new Custom Site Definition.
Create a Feature Handler that will change the versioning setting and Staple the Feature to the Site Definition you are Interested in.
Related
I'm creating a sharepoint project with custom webpart that includes custom user controls.
Is there any way to include a web.config file in this project?
Some of the references I'm including use the web.config file.
Thanks
You can use Property bags for storing configuration settings. Take a look on this post.
You have several options to work with the Property Bags:
SharePoint Designer
PowerShell
Custom code
Codeplex solutions (as SharePoint Property Bag Settings, that provides a farm solution to work with the Property Bag using the SharePoint UI).
So, I believe there is no way.
You have to include your entries in the SharePoint web.config file.
The correct way is not to use a web.config, but if you really need it then use the SharePoint web.config.
Normally custom webparts comes under custom folder in webpart gallery.
I want to make that available in user defined folder. any one know how to do this..
Thanks
If you're using Visual Studio, you can open the webparts Elements.xml file. Within this file you should see the property tag named Group. Change the value of this property from "Custom" to whatever you desire.
Eg
<Property Name="Group" Value="ENTER NAME OF GROUP" />
I am constantly writing custom WebParts but after I deploy them, they always get added to the "Miscellaneous" category. How do I add a WebPart to a specific category?
The category that I am referring to here is the one we see in the "Add Web Parts..." pop up, which is activated when the "Add a Web Part" is clicked on a zone.
Thanks
You need to update your web part manifest file and add the following:
<property Name="Group" Value="Custom" />
Follow the instructions here for details.
I have created a webpart and want to deploy that in Sharepoint. I want to deploy the web part in bin.
I have not created a strong name for dll (webpart code). Is strong name a must for deploying webpart in bin folder?
I have referred this msdn link to do this.
http://technet.microsoft.com/en-us/library/cc263271.aspx
When I go to WebPart gallery and want to populate a web part, it is not appearing in webpart gallery.
Any help will be appreciated.
Strong name isn't a must for Sharepoint development, but is your easiest option.
You could also to use WSPBuilder (SharePoint WSP tool) to deploy your webparts
I usually strong name my assemblies because I don't want to discover it later on that my assemblies needs a strong name, just in case the assembly is being used in some other way than I originally intended.
I've also had some problems relating to events in Sharepoint where reflection is used to execute functions based on class and assembly info (probably stored in database), so if you add a strong name later on then you have to update the places where the old event was used (e.g. on lists), otherwise your functions won't get hit. On the other hand if you have a strong name then this is easy bu using web.config assembly redirect
I like your idea though of having the assembly in bin, that way you can use CAS which provides more control for administrators.
To resolve this problem then you could start out by adding the strong name and deploying the asembly to the GAC, then add your .webpart (or .dwp) to the web part gallery. If that works you can try moving the assembly to the bin folder and then remove the strong name.
You might consider deploying the webpart in a feature and add the code neccessary to add the .webpart file to the gallery on the fly so you dont have to worry about the file, this can be accomplished by using code using a feature receiver
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
site.AllowUnsafeUpdates = true;
SPList list = web.Lists["Web Part Gallery"];
SPFolder root = list.RootFolder;
SPFile spFile = root.Files.Add("ContentEditor.dwp", s);
spFile.Update();
}
or by using caml xml
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="8425EAF8-6GBE-4698-83C7-831CA8614D6D"
Title="WebPart"
Description="Some description"
ImageUrl="GenericFeature.gif"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml" />
</ElementManifests>
</Feature>
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module
Name="WebPart"
List="113"
Url="_catalogs/wp"
RootWebOnly="TRUE">
<File Url="WebPart.dwp" Type="GhostableInLibrary" />
</Module>
</Elements>
I have developed an event handler,called TaskListEventHandler, for the Task list ((ItemAdding, ItemDeleting, ItemUpdating) as feasture using the WSP Builder project template, and I have also added a web part, called RegisterEventHandler, which will be used to bind(register) the events to a list. The webpart is WSP Builder template "Webpart without feature".
Currently, on deployment, my feature and the webpart is getting deployed sucessfully. The web part is also available in the web part gallery.
Now i need to make the web part available in a particular category/group in the gallery using the WSP Builder?
I tried setting the group in the RegisterEventHandler.webpart file (which is automatically created by WSP builder on adding the webpart template inot the project), but still it doesn't show up :(
Cannot import RegisterEventHandler Web Part.
RegisterEventHandler
This webpart is used to register or unregister the event handler to the task list - By Biju (09 Sep 2009)
Biju Webparts
Could anyone please help or suggest me some solution or sample code?
Like Per says.. if you add a webpart feature with wspbuilder it will give you an elements.xml file. This contains an entry like this:
<File Url="WPName.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="MyGroup" />
<Property Name="QuickAddGroups" Value="QuickGroup" />
</File>
Where the properties determine what group is used in the library. Mind you if this web part is already activated in your site re-activating it again wil often not overwrite the existing registration; you'll have to delete the .webpart file from the web part library first.
The category/group of a web part is specified in the elements.xml file (Groups property).
But as Janis comments it seems a little odd to add a web part to add a EventHandler.
If you just want to add the eventhandler to all tasklists on the site where you activate the feature then you can do the add in elements.xml directly.
If you want to add it to a special task list then you can do it in an FeatureReceiver.
If you want to give the enduser the option of selecting which list to add it to then a the web part might be ok, but an application page would probably be a more "SharePoint" way of doing it, or use SPEvent Handler Manager from codeplex