Tuesday, April 14, 2009
You need to create your own custom field that uses the Entity Picker to populate a list of records and allows you to pick one. There is a lot of CAML, XML, Classes, Events and Code to deal with.
Following is sample code to create just that based on another SharePoint list. Simply plug your own DAL instead of the SPQuery and you're up and running.
Step by step instructions:
Thursday, April 9, 2009
a) create an absolute blank sitecolleciton with really nothing in it
stsadm -o createsite -url http://servername -ownerlogin domain\username -owneremail firstname.lastname@example.org
b) activate the publishing feature on the site collection level
stsadm -o activatefeature -name PublishingSite -url http://servername
c) activate the publishing feature on the web level
stsadm -o activatefeature -name PublishingWeb -url http://servername
That's it. go to your url and you will find the most minimalistic publishing site you will be able to get that has all the publishing features activated.
Now you can start building your own site template based on this and be sure that content deployment will give you less headaches should you ever decide to go down that route in future.
The solution is not that obvious though. Looks like the Publishing Feature can't activate because the feature dependency Publishing Resources is not actice. Only solution is to activate the Resources manually via stsadm and then you can activate the publishing feature via the gui.
here's the magic command:
stsadm -o activatefeature -name PublishingResources -url http://YourSharepointSite
Following problem scenario:
We need to be able to colour code calendar entries, add more than just the title to the item and break down the multi day events into separate blocks spanning across the whole day and not just a thin bar at the top which is easily skipped. All this without changing the insides of SharePoint. And the solution could not be simpler!
First of all you will need to create your own WebPart for the calendar. Sound daunting? not at all! you can easily implement the SPCalendarView control to do all the work for you.
Gunnar Peipmann has a great post on how to create a global calendar from multiple sources using the SPCalendarView.
The SpCalendarView control can also accept new Templates. So you copy the Rendering Templates for the Calendar Control from the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES \defaulttemplates.ascx into a new ascx file, rename them and add the fields you want to the Item views. Then hook them up programatically with the SPCalendarView control and render the new output.
WARNING! Don't put the custom Rendering Templates into a subfolder. Although it might make perfect sense, they won't load properly programatically. Just use clear and concise naming conventions for your custom ascx page. Then use the SPControlTemplateManager.GetTemplateByName() function to get hold of the ITemplate programatically and plonk it into the Calendar View.
If you insist on having the custom template in a subfolder, check out Reverse Alchemy's post on loading templates programatically. He will show you how to use Page.LoadControl() as a workaround to SharePoint misbehaving.
You will need to populate the list of events manually though. I.e. use a SPQuery to get the events in a collection, iterate through the collection and create new Calendar Entries based on the list item. But Gunnar's blog will guide you through that. While you're recreating the calendar entries try changing the Backgroundcss attribute of the entry. :-) and voilla you have a colour coded calendar that has all the functionality of the normal calendar.
Ok. Maybe it is not quite as easy. I'll upload a step by step instruction sometime after easter if enough people pester me about it...
Monday, April 6, 2009
Sometimes customers want to have all the functionality of a Picture Library but also that of a Document Library. Specifically the option to have a Excel Report on a bunch of images. Now that sounds simple. Just Expor to Spreadsheet. Well guess what. Some clever dude took that action out of the menu. Why? No idea. Because it does not work? Bollocks. Of course it works. below is how you can get it back again. Simply add a Custom Action to your feature elements and deploy. Happy Exporting.the trick is in dynamically creating the iqy string.
Title="Export To Spreadsheet"