Skip to content

November 15, 2005

CAML:List @ServerTemplate

If you’re trying to work backwards from the CAML element to the SPList object…  The ServerTemplate attribute corresponds to the .BaseTemplate property.  It’s a SPListTemplateType enumeration…  The enumeration values are…

SPListTemplateType.Announcements = 104
SPListTemplateType.Contacts = 105
SPListTemplateType.CustomGrid = 120
SPListTemplateType.DataSources = 110
SPListTemplateType.DiscussionBoard = 108
SPListTemplateType.DocumentLibrary = 101
SPListTemplateType.Events = 106
SPListTemplateType.GenericList = 100
SPListTemplateType.InvalidType = -1
SPListTemplateType.IssueTracking = 1100
SPListTemplateType.Links = 103
SPListTemplateType.ListTemplateCatalog = 114
SPListTemplateType.PictureLibrary = 109
SPListTemplateType.Survey = 102
SPListTemplateType.Tasks = 107
SPListTemplateType.WebPartCatalog = 113
SPListTemplateType.WebTemplateCatalog = 111
SPListTemplateType.XMLForm = 115

How to customize the output of a CorasWorks Web Part

Most CorasWorks’ web parts have a hidden property called Display which can be added to the DWP file which will change the basic display behavior of the web part so that it emits the specific output that you’re looking for.  Because the display tag is hidden it’s not available from the tool pane and must be added to the DWP file directly.

Exporting the DWP

The first step is to configure the CorasWorks component so that it is correctly returning the right data and export that web part as a DWP so there will be a file that is correctly configured.  To do this, make sure that the title bar for the web part is shown.  If the title bar isn’t shown, enter Design mode by clicking on Modify Shared PageDesign this Page. Next, click the down arrow on the right hand side of the web part title bar.  On the context menu select Export…, save the file when prompted.

Creating the Content

The next step to customizing the output is to create the format for the replacement.  The basic format for the replacement is a set of HTML fragments each terminated with a <END> “tag”.  The orders of these elements is header, item (non-selected), footer, and (when appropriate) a final section for selected items.  The Special Site Navigation component is the only component which has a section for selected items at this point.

In each of these sections there are several replacement strings which will be replaced with the value contained in the associated field or property.  An example of the content to make a spreadsheet roll up look like a linked list appears below:

<!–Header//–>

<table border=”0″ width=”100%”>

<END>

<!–Body//–>

<tr><td style=”padding-bottom: 5px” class=”ms-vb”><img src=”/_layouts/images/square.gif”></td><td style=”padding-bottom: 5px” class=”ms-vb”><a HREF=”<%Link%>”><%Display%></a></td></tr>

<END>

<!–Footer//–>

</table>

<END>

Known Replacement Strings

For a list the replacement strings are the field names surrounded by a <% and %>.  You can see this in the above example of <%Link%> and <%Display%> — these are both fields in the lists being rolled up by CorasWorks’ web part.

For special site navigation, there are only three replacement strings that are valid:

  • PageURL –  The Url of the page to link to.  This value comes from the underlying navigation list.
  • PageTitle – The text to display for the page.  In other words, the friendly name for the page. This value comes from the underlying navigation list.
  • Target – The target to open the window in, from the web part properties.

Adding the Tag

Adding the tag to the XML is simple, but is very specific.  First, the value must be encoded or placed in a CDATA section so that it is not interpreted as a part of the XML.  The best way to do this is the CDATA section so the Display property will still be readable.

First, add a new <Display></Display> tag set prior to the closing </WebPart> tag in the DWP file.  Next copy the xmlns attribute from the last tag prior to the new display tag you just added and add that attribute to the display tag.  Each web part uses it’s namespace for the Display tag.  You must provide this xmlns attribute for the Display node or it will not work.

In the middle of the <Display></Display> tag set add a CDATA node by adding <![CDATA[ ]]>.  In the middle of the two brackets ‘[ ]’ add the content that you created above.

Save the DWP file.

Trying the modified file

The next step is to import the modified DWP file.  From the Modify Shared Page menu select Add Web Parts and Import.  Click the browse button and locate the DWP file that you modified.  Click the Upload button to upload the control.  Drag the control on to the page from the tool pane.

The display of the links or navigation should reflect the updated HTML that you provided.

Troubleshooting

If for some reason you don’t see any modified display make sure that your <Display> tag has the correct xmlns attribute.  It should match the other xmlns attributes in the file.

How to Add a Reference to an Assembly in a Web Part

Adding a reference to a shared library from a web part is not as simple as using visual studio to add a reference to a project output or a fixed DLL on the file system.  In addition to adding the reference to the project itself, you must add the DLL to the cab file and modify the manifest.xml so that the referenced DLL is deployed with the web part.  This How To shows you what must be done for the web part to deploy correctly when referencing another assembly.

Adding the reference to the project

Adding the reference to the project can be done with the following steps:

  1. Right Click References under the web part project and click Add Reference…
  2. Click the Projects tab.
  3. Click the project and click Select or double-click the project so that the project appears in the Selected Components list at the bottom of the dialog.
  4. Click the OK button.

Now you have added the reference to the project.  Next is adding the DLL to the CAB file.

Adding the Referenced DLL to the CAB file

The process of adding the referenced DLL to the CAB file is easy.  Simply follow these steps:

  1. Right click the setup (CAB) project, select Add from the context menu, and finally Project Output…
  2. Select the correct project for the output file in the Project drop down at the top of the dialog.
  3. Click the Primay output item in the list.
  4. Click the OK button.

Now that you’ve added the DLL to the Cab file it’s time to add the file to the manifest.xml.

Adding the Reference to Manifest.xml

The final step is to add the file to manifest.xml so that STSADM will deploy the DLL for you when the web part is deployed.  You can do this by following these steps:

  1. Open the manifest.xml file for the web part project in Visual Studio
  2. Locate the </Assemblies> tag.
  3. Add a new tag <Assembly FileName=”” /> immediately before the </Assemblies> tag
  4. Add the name of the referenced DLL to the FileName attribute of the <Assembly> tag that you just added.  Note that the name should not include any path information.  It should be the complete name of the referenced DLL—including the DLL extension.
  5. Safe the file.

Now you have completed the changes necessary for the web part project to deploy the referenced DLL along with your web part.

Recent Posts

Public Speaking