La plantilla "dvt_1.body" es el cuerpo de la lista, tiene tres parametros, las filas "Rows" (2), la primera fila que vamos a mostrar "FirstRow" (3) y la última "LastRow" (4), mantiene unas variables con el orden en que se están mostrando los datos una para el grupo "AdHocGroupDir" (5) y otra para el orden "AdHocSortDir" (15)
1: <xsl:template name="dvt_1.body">
2: <xsl:param name="Rows"/>
3: <xsl:param name="FirstRow"/>
4: <xsl:param name="LastRow"/>
5: <xsl:variable name="AdHocGroupDir">
6: <xsl:choose>
7: <xsl:when test="$dvt_groupdir='desc'">
8: descending
9: </xsl:when>
10: <xsl:otherwise>
11: ascending
12: </xsl:otherwise>
13: </xsl:choose>
14: </xsl:variable>
15: <xsl:variable name="AdHocSortDir">
16: <xsl:choose>
17: <xsl:when test="$dvt_sortdir='desc'">
18: descending
19: </xsl:when>
20: <xsl:otherwise>
21: ascending
22: </xsl:otherwise>
23: </xsl:choose>
24: </xsl:variable>
Para cada fila de datos en "dvt_1.body" hay también una serie de variables en función de lo que seleccionemos en FrontPage, en "Ordenar y Agrupar", si mantendremos juntos los datos "KeepItemsTogether" (2), si ocultaremos los detalles "HideGroupDetail" (3) y el estilo del grupo "GroupStyle" (4) después la plantilla comprueba si la fila esta entre la primera y última fila a mostrar y comienza a dibujar cada fila.
1: <xsl:for-each select="$Rows">
2: <xsl:variable name="KeepItemsTogether" select="false()"/>
3: <xsl:variable name="HideGroupDetail" select="false()"/>
4: <xsl:variable name="GroupStyle" select="'auto'"/>
5: <xsl:if test=" (position() >=$FirstRow and position() <= $LastRow) or $KeepItemsTogether">
6: <xsl:if test="not($HideGroupDetail)" ddwrt:cf_ignore="1">
7: <TR style="display:{$GroupStyle}">
La primera columna de esta vista de tareas es el título (1) en este caso la columna esta vinculada al elemento (3 y 4) el icono de "Nuevo" (7 y 9)
1: <!--Título-->
2: <TD Class="{$IDAIHSOH}"> 3: <a onfocus="OnLink(this)" href="{$URL_Display}?ID={@ID}" 4: ONCLICK="GoToPage('{$URL_Display}?ID={@ID}');return false;" target="_self"> 5: <xsl:value-of disable-output-escaping="no" select="@Title"/>
6: </a>
7: <xsl:if test="ddwrt:IfNew(string(@Created))">
8: <IMG SRC="/_layouts/3082/images/new.gif" alt="Nuevo"/>
9: </xsl:if>
10: </TD
La segunda columna es el campo "Asignado a", si el campo esta vacio no hace nada (4 y 5) en caso contrario como es un campo tipo usuario si no se quiere mostrar la información del usuario en línea el muñequito del messenger (8) solo se dibujará el hipervínculo a la página del usuario 'UserInfo' (9)
1: <!--Asignado a-->
2: <TD Class="{$IDAIHSOH}"> 3: <xsl:choose>
4: <xsl:when test="@AssignedTo=''">
5: </xsl:when>
6: <xsl:otherwise>
7: <xsl:choose>
8: <xsl:when test="''='FALSE'">
9: <A HREF="{ddwrt:URLLookup('UserInfo', 'AssignedTo', string(@ID))}"> 10: <xsl:value-of select="@AssignedTo"/>
11: </A>
12: </xsl:when>
En caso contrario, (1) mostrará la información de usuario la condición (3) es para mostrar el muñequito a la izquierda o a la derecha.
1: <xsl:otherwise>
2: <xsl:choose>
3: <xsl:when test="concat('FALSE','')='FALSE'"> 4: <table cellpadding="0" cellspacing="0" MsoPnlId="data">
5: <tr>
6: <td style="padding-right: 3px;">
7: <xsl:choose>
8: <xsl:when test="ddwrt:UserLookup(string(@AssignedTo), 'EMail')=''">
9: <img border="0" valign="middle"
10: height="12" width="12"
11: src="/_layouts/images/blank.gif"/>
12: </xsl:when>
13: <xsl:otherwise>
14: <img border="0" valign="middle" height="12" width="12"
15: src="/_layouts/images/blank.gif"
16: onload="IMNRC('{ddwrt:UserLookup(string(@AssignedTo), string($EMail))}')" 17: id="imn{ddwrt:Counter()}"/> 18: </xsl:otherwise>
19: </xsl:choose>
20: </td>
21: <td style="padding-top: 1px;" class="ms-vb">
22: <A HREF="{ddwrt:URLLookup('UserInfo', 'AssignedTo', string(@ID))}"> 23: <xsl:value-of select="@AssignedTo"/>
24: </A>
25: </td>
26: </tr>
27: </table>
28: </xsl:when>
29: <xsl:otherwise>
30: <nobr>
31: <span>
32: <A HREF="{ddwrt:URLLookup('UserInfo', 'AssignedTo', string(@ID))}"> 33: <xsl:value-of select="@AssignedTo"/>
34: </A>
35: <img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/>
36: <xsl:choose>
37: <xsl:when test="ddwrt:UserLookup(string(@AssignedTo), 'EMail')=''">
38: <img border="0" height="12" width="12" src="/_layouts/images/blank.gif"/>
39: </xsl:when>
40: <xsl:otherwise>
41: <img border="0" height="12" width="12" src="{$ImagesPath}blank.gif" 42: onload="IMNRC('{ddwrt:UserLookup(string(@AssignedTo), string($EMail))}')" 43: id="imn{ddwrt:Counter()}"/> 44: </xsl:otherwise>
45: </xsl:choose>
46: </span>
47: </nobr>
48: </xsl:otherwise>
Termina la plantilla "dvt.body"
1: </xsl:choose>
2: </xsl:otherwise>
3: </xsl:choose>
4: </xsl:otherwise>
5: </xsl:choose>
6: </TD>
La plantilla "dvt_1.toolbar" es la barra de menú que aparecerá si hemos marcado en las opciones del estilo de la vista "Mostrar la barra de herramientas", aquí podemos introducir nuevos botones con nuestras acciones (26 y 27), hay que tener en cuenta que si después de hacer cambios, cambiamos las opciones en FrontPage, nuestros cambios pueden desaparecer. Esta plantilla toma un parámetro (3) "Rows" que es usado para pasarlo a la plantilla "dvt.filterfield" si se esta filtrando la vista, aquí por ejemplo yo suelo poner en vez de "Agregar nuevo Element" "Añadir peticiones" por ejemplo.
2: <xsl:template name="dvt_1.toolbar">
3: <xsl:param name="Rows"/>
4: <table width="100%" cellpadding="0" cellspacing="0" border="0" MsoPnlId="data">
5: <tr>
6: <td colspan="2" class="ms-partline">
7: <IMG SRC="/_layouts/images/blank.gif" width="1" height="1" alt=""/>
8: </td>
9: </tr>
10: <tr>
11: <td class="ms-addnew" style="padding-bottom: 3px"><img src="/_layouts/images/rect.gif" alt=""/>
12: <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
13: ddwrt:nbsp-preserve="yes"
14: disable-output-escaping="yes">
15: &nbsp;
16: </xsl:text>
17: <a class="ms-addnew" ID="idAddNewTask" href="{$URL_New}" 18: ONCLICK="javascript:NewItem('{$URL_New}', true);javascript:return false;" 19: target="_self">
20: Agregar nuevo elemento
21: </a>
22: </td>
23: </tr>
24: <tr>
25: <td><IMG SRC="/_layouts/images/blank.gif" width="1" height="5" alt=""/></td>
26: </tr>
27: </table>
28: <xsl:if test="$dvt_adhocmode = 'filter'" ddwrt:cf_ignore="1">
29: <table cellSpacing="0" cellPadding="2" border="0" class="ms-toolbar"
30: style="margin-left: 3px; margin-right: 5px;">
31: <tr>
32: <th nowrap="true">
33: <table>
34: <tr>
35: <td class="ms-toolbar" nowrap="true">
36: <xsl:call-template name="dvt.filterfield">
37: <xsl:with-param name="fieldname">@Title</xsl:with-param>
38: <xsl:with-param name="fieldtitle">Título</xsl:with-param>
39: <xsl:with-param name="Rows" select="$Rows"/>
40: <xsl:with-param name="fieldtype">text</xsl:with-param>
41: </xsl:call-template>
42: </td>
43: </tr>
44: </table>
45: </th>
46: <th nowrap="true">
47: <table>
48: <tr>
49: <td class="ms-toolbar" nowrap="true">
50: <xsl:call-template name="dvt.filterfield">
51: <xsl:with-param name="fieldname">@AssignedTo</xsl:with-param>
52: <xsl:with-param name="fieldtitle">Asignado a</xsl:with-param>
53: <xsl:with-param name="Rows" select="$Rows"/>
54: <xsl:with-param name="fieldtype">text</xsl:with-param>
55: </xsl:call-template>
56: </td>
57: </tr>
58: </table>
59: </th>
60: <td width="99%"></td>
61: </tr>
62: </table>
63: </xsl:if>
64: </xsl:template>
La plantilla es "dvt.headerfield" monta los nombres de los campos (en la parte superior de la vista), usa 4 parametros, el nombre del campo "fieldname" (2), el nombre que se va a mostrar "fieldtitle" (3), si se puede ordenar por ese campo "sortable" (4) por defecto si, si el campo es un campo para indicar adjuntos "attachments" (5) por defecto no.
1: <xsl:template name="dvt.headerfield">
2: <xsl:param name="fieldname"/>
3: <xsl:param name="fieldtitle"/>
4: <xsl:param name="sortable">1</xsl:param>
5: <xsl:param name="attachments">0</xsl:param>
6: <xsl:choose>
7: <xsl:when test="($dvt_adhocmode = 'sort' or $dvt_fieldsort = '1')and $sortable">
8: <xsl:variable name="sortfield">
9: <xsl:choose>
10: <xsl:when test="substring($fieldname, string-length($fieldname) - 5) = '(text)'">
11: <xsl:value-of select="substring($fieldname, 1, string-length($fieldname) - 6)"/>
12: </xsl:when>
13: <xsl:when test="substring($fieldname, 1, 1) = '@'">
14: <xsl:value-of select="substring($fieldname, 2)"/>
15: </xsl:when>
16: <xsl:otherwise>
17: <xsl:value-of select="$fieldname"/>
18: </xsl:otherwise>
19: </xsl:choose>
20: </xsl:variable>
21: <xsl:variable name="linkdir">
22: <xsl:choose>
23: <xsl:when test="$dvt_sortfield = $sortfield and $dvt_sortdir = 'asc'">desc</xsl:when>
24: <xsl:otherwise>asc</xsl:otherwise>
25: </xsl:choose>
26: </xsl:variable>
27: <xsl:variable name="sortText">
28: <xsl:choose>
29: <xsl:when test="$linkdir='desc'">' + 'desc' + '</xsl:when>
30: <xsl:otherwise>' + 'asc' + '</xsl:otherwise>
31: </xsl:choose>
32: </xsl:variable>
33: <a>
34: <xsl:attribute name="href">javascript:
35: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_sortfield= 36: {',$sortfield,'};dvt_sortdir={',$sortText,'}'))"/> 37: ;
38: </xsl:attribute>
39: <xsl:choose>
40: <xsl:when test="$attachments">
41: <xsl:value-of select="$fieldtitle" disable-output-escaping="yes"/>
42: </xsl:when>
43: <xsl:otherwise>
44: <xsl:value-of select="$fieldtitle"/>
45: </xsl:otherwise>
46: </xsl:choose>
47: <xsl:if test="$dvt_sortfield = $sortfield">
48: <xsl:choose>
49: <xsl:when test="$dvt_sortdir = 'asc'">
50: <img border="0" alt="Ascendente"
51: src="{ddwrt:FieldSortImageUrl('Desc')}"/> 52: </xsl:when>
53: <xsl:when test="$dvt_sortdir = 'desc'">
54: <img border="0" alt="Descendente"
55: src="{ddwrt:FieldSortImageUrl('Asc')}"/> 56: </xsl:when>
57: </xsl:choose>
58: </xsl:if>
59: </a>
60: </xsl:when>
61: <xsl:otherwise>
62: <xsl:choose>
63: <xsl:when test="$attachments">
64: <xsl:value-of select="$fieldtitle" disable-output-escaping="yes"/>
65: </xsl:when>
66: <xsl:otherwise>
67: <xsl:value-of select="$fieldtitle"/>
68: </xsl:otherwise>
69: </xsl:choose>
70: </xsl:otherwise>
71: </xsl:choose>
72: <xsl:if test="$dvt_filterfield=$fieldname" ddwrt:cf_ignore="1">
73: <img alt="Filtro" src="{ddwrt:FieldFilterImageUrl('')}"/> 74: </xsl:if>
75: </xsl:template>