How to Deploy SharePoint WebParts

http://www.cmswire.com/cms/tips-tricks/how-to-deploy-sharepoint-webparts-000618.php

There are several ways to skin the Webparts deployment cat, each with a few pluses and minuses. Thanks to Mark Harrison we have have a quick and pragmatic list of the options, complete with instructions.

Method 1 – manual

  • Copy assembly DLL to either
    – /bin directory for a given IIS virtual server (e.g., c:\inetpub\wwwroot\bin)
    – Global Assembly Cache (e.g., c:\windows\assembly)
  • Copy DWP file to C:\Inetpub\wwwroot\wpcatalog
  • Copy resources to
    – For GAC-registered parts, C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources
    – For Web Parts in the /bin directory, C:\Inetpub\wwwroot\wpresources
  • Adjust web.config
    – Register as SafeControl
    – Select Code Access Security settings

Method 2: CAB File

  • CAB file should contain
    -Assembly DLL
    -DWP file(s)
    -Manifest.XML
    -Resource files (if needed)

  • CAB won’t contain
    – Code Access Security settings
  • Server-side object model has methods for deploying such a CAB file
  • Deploy with STSADM.EXE
    Located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\BIN
    Add it to your path
    Stsadm -o addwppack -filename filename [-globalinstall] [-force]

Method 3: MSI File via WPPackager

  • All of the features of CAB file deployment, but with
    – Code Access Security support
    – Ability to uninstall via Control Panel
  • Get WPPackager.exe
  • Add additional files to project for use by WPPackager
  • Run WPPackager after project is built
Advertisements

Content Query Web Part – Field Types

http://blogs.inetium.com/blogs/bcaauwe/archive/2008/12/01/content-query-web-part-field-types.aspx

Over the last few months I have had to configure various Content Query Web Parts (CQWP) to provide portal rollups that can be pre-packaged and re-configured in the SharePoint UI instead of having to use SharePoint Designer when using Data View Web Parts.

I could go into the basics of setting up a CQWP, but since others have done it for us I’ll just provide some link love here. Even though this post if fairly old it provides a TON of value for those getting started with the CQWP, but the main thing I find missing is how to identify the items needed in the CommonViewFields property. You can find the internal field name pretty easy by going to your list settings, and then look at the URL when you hover over the column you want to identify. The Field Query String parameter gives you the internal name you need.

Now that you have the internal name for the columns you need, now you need the column type.  I haven’t been able to find a decent resource for all of the column types, so I figured this is where I needed to list them all out:

Display Column Type

Internal Column Type

Single line of text

Text

Multiple lines of text

Note

Choice

Choice

Number

Number

Currency

Currency

Date and Time

DateTime

Lookup

Lookup

Yes/No

Boolean

Person or Group

User

Hyperlink or Picture

URL

Calculated

Calculated

 

Of course these are all the default column types you can create, however there are some others, like the Publishing columns such as:

Display Column Type

Internal Column Type

Publishing Image

Image

Publishing HTML

HTML

Another nice way to see what these values are would be to use PowerShell.  I will often drop into PowerShell and look at the fields in a specific list to view the internal name, along with other variables, the following lines will output a table of all fields associated with a list and the Display Name, Internal Name, Display Column Type, and the Internal Column Type:

 

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

 

$site = new-object Microsoft.SharePoint.SPSite(“http://moss150”)

$web = $site.OpenWeb()

$list = $web.Lists[“CQWP”]

$list.Fields | Format-Table Title, InternalName, TypeDisplayName, TypeAsString

Having these items should now set you up to have all the information you need to customize your Content Query Web Part. Just create a customized template in the ItemStyle.xsl (or create your own custom XSL file and link to it using the ItemXslLink property in your .webpart file) to render the information you need and you should be ready to start utilizing the infamous Content Query Web Part.

Displaycustom fields in a Content Query Web PartD

http://msdn.microsoft.com/en-us/library/ms497457.aspx

1.

Add a Content Query Web Part to a page.
* In the Query section, set the Source to show items from the Knowledge Base Articles document library (list). Set the list type and content type accordingly.
* In the Presentation section, set the Item Style to Title and description.

2.

Edit the properties in the Web Part file to display custom fields. To access the .webpart file for the Web Part, on the Web Part’s edit menu, click Export.
* Office SharePoint Server 2007 generates a .webpart file with the complete set of properties that are available for this Web Part. The .webpart file is an XML file that you can edit using a text editor.
3.

In the .webpart file, locate the CommonViewFields property. Use this property to specify the additional fields you want to display in the Web Part. Add the internal names of the columns and the type.
Copy Code

KB_x0020_Title,Text;Product,Text;

NoteNote:

You cannot use your columns’ display names in this property. You can find the internal column names by checking the properties of the column in the list or document library. Right-click the column, and then click Properties. The internal name of a column appears in the Address (URL) property after ‘Field=’. In the Knowledge Base Articles scenario, the columns are Knowledge Base Article and Product and their internal names are KB_x0020_Title and Product, respectively.
4.

Map these internal column names to the columns’ Title and Description present in the XSLT transformations. To do this, edit the DataColumnRenames property.
Copy Code

KB_x0020_Title,Title;Product,Description

NoteNote:

The default XSLT transformations can render the following four fields: Title, Description, LinkUrl, and ImageUrl. In your DataColumnRenames property, verify that the names you specify match the names in the XSLT transformations; that is, Title, Description, LinkUrl, and ImageUrl.
5.

Save the .webpart file locally.
6.

In the Web page, delete the Content Query Web Part you added in step 1.
7.

Import the .webpart file and add the Web Part to your page. To import the .webpart file, click Page, click Add Web Parts, and then click Import. Browse to the .webpart file, and then click Upload.
8.

Drag the Web Part to the appropriate zone in the page. The Web Part should display the Knowledge Base Title and the product name.

Customize the Content Query Web Part by using Custom Properties

http://msdn.microsoft.com/en-us/library/aa981241.aspx

CommonViewFields

Requests additional fields, which is necessary because the Content Query Web Part does not return all fields for all items automatically. You must request fields to render in an XSLT transformation.

This property is additive, meaning that you can add more than one CommonViewField to a Content Query Web Part and extend its base properties, such as FieldDescription and FieldTitle.

QueryOverride

Bypasses limits to query behavior imposed by the Content Query Web Part UI. Makes it possible to specify the query portion of a cross-list query in CAML.

When the QueryOverride property is set, the UI for filtering, sorting, and grouping appears dimmed in the tool pane. For example, by default the Content Query Web Part allows three filters, and you might want to add more and ensure that the customized fields and behavior persists in the UI.


WebsOverride

Determines whether the cross-list query should recurse subsites. By default, Office SharePoint Server 2007 recurses subsites, meaning that the parent site and its child sites are displayed.

When the WebsOverride property is set, the Content Query Web Part does not recurse, and displays results from only the specified site.

ListsOverride

Overrides the list behavior in Office SharePoint Server 2007, and supports several types of lists, such as Page Libraries, the General List base type, and specific list types. You can use this custom property to set any list type, even those not enumerated in the UI because the template is not defined at the root or is a base type.

List types are defined in the List element reference topic in the Windows SharePoint Services 3.0 SDK.

ViewFieldsOverride

Gives the Content Query Web Part the ability to request a set of fields from the query that you specify, instead of making the automatic request in Office SharePoint Server 2007 for the base fields.

DataColumnRenames
Gives the Content Query Web Part the ability to rename columns before the data is passed to the XSLT transformation for rendering.