I have two lists Client and Project, each Client has from 0 to N Project stocked in his SPLookupField where multi values are allowed. And I created a new computed Column in the Client List where it shows a link to the page of all of my Projects only when he has indeed project otherwise it won't show the link. Here's the field in the schema of the Client List:
<Field ID="{BD65ECB7-1BFE-4154-844E-3FDC9A760830}" Name="ProjectsLink" StaticName="Projects" ShowInNewForm="FALSE" ShowInEditForm="FALSE" ShowInDisplayForm="FALSE" Sortable="FALSE" Filterable="FALSE" Type="Computed" DisplayName="Projects" ClassInfo="Icon" AuthoringInfo="$Resources:core,linked_to_item;" >
<DisplayPattern>
<HTML><![CDATA[<a href="]]></HTML>
<URL Cmd="DISPLAY" />
<HTML><![CDATA[" onclick="GoToLink(this);return false;" target="_self">]]></HTML>
<HTML><![CDATA[<img Width="25px" Height="20px" border="0" alt="]]></HTML>
<Field Name="FileLeafRef" />
<HTML><![CDATA[" src="/_layouts/DISPLAY.png">]]></HTML>
<HTML><![CDATA[</a>]]></HTML>
</DisplayPattern>
</Field>
so in order to add this Field in my List I have created an XSLT file but I didn't know how to indicate my second condition because it depends on a method in my cs file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
version="1.0" exclude-result-prefixes="xsl msxsl ddwrt"
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:asp="http://schemas.microsoft.com/ASPNET/20"
xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:SharePoint="Microsoft.SharePoint.WebControls"
xmlns:ddwrt2="urn:frontpage:internal" ddwrt:oob="true">
<xsl:template name="FieldRef_ProjectsLink_body" ddwrt:dvt_mode="body" match ="FieldRef[@Name='ProjectsLink']" mode="Computed_body">
<xsl:param name="thisNode" select="."/>
<xsl:param name="ShowAccessibleIcon" select="0"/>
<xsl:param name="folderUrlAdditionalQueryString" select="''"/>
<xsl:variable name="ID">
<xsl:call-template name="ResolveId">
<xsl:with-param name="thisNode" select ="$thisNode"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$XmlDefinition/List/@TemplateType != 301"> <!--and Condition2-->
<a onfocus="OnLink(this)" href="{$FORM_DISPLAY}&ID={$ID}&ContentTypeID={$thisNode/@ContentTypeId}" onclick="EditLink2(this,{$ViewCounter});return false;" target="_self">
Details -
</a>
<a onfocus="OnLink(this)" href="/_LAYOUTS/Projects.aspx?ID={$ID}" onclick="EditLink2(this,{$ViewCounter});return false;" target="_self">
Projects
</a>
</xsl:when>
<xsl:otherwise>
<a onfocus="OnLink(this)" href="{$FORM_DISPLAY}&ID={$ID}" onclick="GoToLink(this);return false;" target="_self">
Details -
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
and in my ClientManagement.cs file I have this function that gives me the number of all client's projects :
public static int getProjectsCount(int pClientID)
{
SPSite mysite = new SPSite(SPContext.Current.Web.Site.Url);
SPWeb myweb = mysite.OpenWeb();
SPListItem myContact = myweb.Lists["Client"].Items.GetItemById(pClientID);
SPFieldLookupValueCollection fieldValues = myContact["Projects"] as SPFieldLookupValueCollection;
return fieldValues.Count;
}
So my question is how to call this function my XSL file to use it as a condition??