Thursday, October 18, 2012

AttachmentField control in SharePoint


The SharePoint AttachmentsField is used to display attachments from an SP list item.

<td align="center" id="att_{@ID}">
<xsl:if test="@Attachments='1'">
<SharePoint:AttachmentsField ID="att{@ID}" ControlMode="Display" ListId="{$ListID}" ItemId="{@ID}" FieldName="Attachments" visible="true" runat="server" />
</xsl:if>
</td>

The HTML that is rendered includes a table with a row for each attachment. The anchor tag look something like:

<a href="/student-affairs/athletics/athletics-w/basketball/Lists/Schedule/Attachments/11/statistics.html">20090312.6.html</a>

Mod operator to control Table Rows in XSL


The Mod operator returns the remainder left after division is performed. If you have a table and you need to have a certain amounts of columns before another row is created, use the mod operator.

The following example will create a new row after 3 columns are created.

<xsl:if test="position() mod 3 = 1">
<xsl:text disable-output-escaping="yes"><![CDATA[ <tr> ]]></xsl:text>
</xsl:if>
   <td valign="top">
    <img alt="" src="{@ImgURL}"/>
    <xsl:call-template name="dvt_2" />
   </td>
<xsl:if test="position() mod 3 = 3">
<xsl:text disable-output-escaping="yes"><![CDATA[ </tr> ]]></xsl:text>
</xsl:if>

Monday, September 24, 2012

Customizing the Summary Links with custom itemStyles.xslt


The Summary Links control (PublishingWebControls:summarylinkfieldcontrol) allows you to specify your own styles using the ItemXslLink property as shown below. 

<PublishingWebControls:summarylinkfieldcontrol ItemXslLink="/Style Library/XSL Style Sheets/InsideHomeItemStyle.xsl" .../>

In SP Designer, you can copy an existing xsl file and rename it, you can then update the file with your own styles and template names.

As a demo of how this works, the following New Home page layout has two Summary Link areas.


The custom itemStyles.xsl file I created has only 2 styles to chose from; insideHome1 & insideHome2. Both styles include a bullet icon in front of the link but insideHome1 colors the link teal, insideHome2 colors the link orange.

If you have a Links Webpart that you've added to a zone in your publishing page, you can export the webpart and modify the webpart file with the following xml:


<property name="HeaderXslLink" type="string">/Style Library/XSL Style Sheets/CustomHeader.xsl</property>
<property name="ItemXslLink" type="string">/Style Library/XSL Style Sheets/CustomItemStyle.xsl</property>

Save, add and upload your webpart. Your new header and styles will now be available.

Tuesday, September 18, 2012

Using the Previous function to supress Detail rows


When your query in Crystal does not return Distinct records, you may want to supress rows in the Details section based upon the previous value of a field or fields. Add the following code to the Supress code area in the Section Expert for the Details section:

 
if (not onfirstrecord) then
    previous({RDS_CLASS_VW.CLASS_CLASS_NBR})={RDS_CLASS_VW.CLASS_CLASS_NBR}

Wednesday, September 12, 2012

Using the IN Operator in a CAML Query

The In operator is used in an SQL query allows you to specify multiple values in a
WHERE clause. The CAML query language also uses the IN operator, in place of using multiple ORs, to return multiple values of a column.

<In><FieldRef Name='Col1'/>
    <Values>
        <Value Type='Text'>A</Value>
        <Value Type='Text'>B</Value>
        <Value Type='Text'>C</Value>
    </Values>
</In>

Monday, July 30, 2012

Using PowerShell to downgrade a SharePoint v4 site to v3


Use the following powershell commands on a SharePoint front end server to downgrade a v4 site to v3.

$Web=Get-SPWeb http://<site name>/<site>
$Web.UIVersion=3
$Web.UIVersionConfigurationEnabled=$true
$Web.update()

Wednesday, July 18, 2012

Using the Eval method in a SharePoint master or layout page

Examples of using Eval method in SharePoint master or layout page:


In this example "Include Time" is a SP yes/no field where we're checking for a value of "yes":



<%# Eval("Include Time").ToString() == "True" ? " (" + Eval("Start Time","{0:hh:mm tt}") + ")" : "" %>



In this example "Active" is a SP yes/no field where it's casted to a boolean value and then used to control visibility of an asp:Label control:



Visible='<%# bool.Parse(Eval("Active").ToString()) %>'

Another example of setting the Visible property. If the value of Descrition is null, hide the control:

Visible='<%# bool.Parse(Eval("Description") == null ? "False" : "True") %>'