Hide Site Definitions via a Feature

Creating site definitions is a good way to deploy customisations for different projects or clients. However if they all run on the same farm, how do you stop users from creating sites based on the wrong project?

By default if you create a site definition, it will appear in the Site Actions -> Create Site sites list (publishing feature), unless you have limited the site templates available through site settings. 

But what if you dont want to allow the site owners access to provide these templates to their users? You can restrict it at the Site Definition level.

  1. Create an empty site feature called something like ‘Project.EnableSiteTemplates’ (set hidden=”TRUE” if you want to control the feature activation via Site Def or STSADM only – not through Site Settings) 
  2. In the webtemp*.xml for your site definition, in each <Configuration> template node set the VisibilityFeatureDependency property to the GUID of your newly created feature so that the site only appears for users to select in Create Site box when that feature has been activated. eg. VisibilityFeatureDependency=”7C30466D-62A2-43eb-99EB-7650E5D14B77″
  3. In your onet.xml file of the project Site Definition, enable the ‘Project.EnableSiteTemplates’ feature in the <SiteFeatures> section, so when your new site collection is created it also enables your site templates for this project. 
This is the same principle behind hiding sites based on publishing infrastructure until the prerequisite features for Publishing have been enabled.
Note: The Site Owner will actually see and be able to select the custom site templates on the ‘Page Layout and Site Template Settings’ page even when the feature is not activate on the site collection. However nobody can actually see the site on the ‘Create Site’ page until the feature is activated.

Comparing to a time in a CQWP

I had been struggling to find out how to compare a time in a CAML statement for a while now (not that I was looking particularly hard though). To do a date comparison is easy using the <Today/> tag, but I was (and still am!) confused as to why the <Now/> tag doesn’t work in the query, as it’s listed in the SDK. Very frustrating!

However I came across this blog on the Microsoft ECM team blog, where buried in the comments trail there was a little gem!

Normally to compare a date in a Query override you would use something like:

<Geq><FieldRef Name=”Expires” /><Value Type=”DateTime”><Today /></Value></Geq>

this will compare the whole date, so if the items date is today it will be included, no matter what the time. If you want to compare the time also, you need to add this IncludeTimeValue attribute to the Value tag:

<Geq><FieldRef Name=”Expires” /><Value Type=”DateTime” IncludeTimeValue=”TRUE”><Today /></Value></Geq>

Pretty simple, one of those annoying little bits of crucial info that’s really hard to find!

ServerTemplate Numbers

I’ve put these here because I keep having to trawl the web for these numbers each time I want to do a CQWP… Next time I’ll just print them out antd stick them to the wall!

   
100 Generic list
101 Document library
102 Survey
103 Links list
104 Announcements list
105 Contacts list
106 Events list
107 Tasks list
108 Discussion board
109 Picture library
110 Data sources
111 Site template gallery
112 User Information list
113 Web Part gallery
114 List template gallery
115 XML Form library
116 Master pages gallery
117 No-Code Workflows
118 Custom Workflow Process
119 Wiki Page library
120 Custom grid for a list
130 Data Connection library
140 Workflow History
150 Gantt Tasks list
200 Meeting Series list
201 Meeting Agenda list
202 Meeting Attendees list
204 Meeting Decisions list
207 Meeting Objectives list
210 Meeting text box
211 Meeting Things To Bring list
212 Meeting Workspace Pages list
300 Portal Sites list
301 Blog Posts list
302 Blog Comments list
303 Blog Categories list
850 Page Library
1100 Issue tracking
1200 Administrator tasks list
2002 Personal document library
2003 Private document library

SP1 Publishing Additions

The other day I stumbled across some new additions to the properties of publishing pages that MOSS Service Pack 1 has given us.

If you view the properties of a Publishing page, you can now see that the Schedule End Date has some extra email review options.

Never – send a content review. This can be used if you don’t want the page to actually expire and disappear on a certain date, but you can now send a regular email to authors reminding them to update their content. Before SP1 you had to write some code to achieve this.

On the following date – Notify Page Contact prior to end date. Now with SP1 you can set this option to send an email before the page expires. Very handy for easy setting of automatic reminders.

Page Contact – With SP1 you can now add a contact picture if you manually add a contact rather than picking a SP user.

sp1publishingadditions_1.jpg

sp1publishingadditions_2.jpg

Pre-SP1 publishing screen

sp1publishingadditions_3.jpg

Customise List View page

See previous post for basic steps regarding setting up a DataView.

Open SharePoint Designer (SPD) and edit the dispForm.aspx page of your list. Set up a DataView object on this page that joins your lists, as seen in the previous post.dataviews2_1.jpg

You can modify the layout and text of the Dataview through the ‘Design’ view in SPD, however for more advanced customisations open the ‘Code’ view and start hacking the XSL! Inside the DataFormWebPart (DataView that SPD creates) there is an <XSL > tag where you can modify the html around the data elements, or change the data elements/parameters etc yourself. Read the rest of this entry »

Using XSL to render SharePoint webparts

Certain SharePoint web parts such as the Content by Query web part, Table of Contents web part, and the Summary Links web part have a property that allows you to select the XSL stylesheet that controls the HTML output of the webpart.

This allows us to override the default Microsoft html layout for each of the webparts. Which is fantastic as much of the default html output of web parts is rubbish html code, horrible for accessibility, and also full of sizable and unnecessary html.

For example a html list, such as the Summary Links web part, you would expect to be rendered in a <ul> <li> list tags, but by Microsoft default is rendered as nested tables. Not good…

By default, you can select the type of Item Style you want from the web part properties in the ‘Modify Web Part’ menu option, giving you a list of styles to choose from. The list of these styles corresponds to the xsl templates in the XSL stylesheet.contentqueryxsl1.jpg

So… how to change this or add your own style? Read the rest of this entry »