Solved

SharePoint Dataview XSL Help

Posted on 2013-01-16
2
981 Views
Last Modified: 2013-01-20
Hi experts!

Currently my dataview is only using 1 item (image of left, text on right)

How do I change it to show 4 items horizontally (image on top, text bottom)

This is my XSL code

<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">
	<xsl:output method="html" indent="no"/>
	<xsl:decimal-format NaN=""/>
	<xsl:param name="dvt_apos">&apos;</xsl:param>
	<xsl:variable name="dvt_1_automode">0</xsl:variable>
	<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
		<xsl:call-template name="dvt_1"/>
	</xsl:template>
	
	<xsl:template name="dvt_1">
		<xsl:variable name="dvt_StyleName">RepForm3</xsl:variable>
		<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
		<xsl:variable name="RowLimit" select="1" />
		<table border="0" width="100%">
			<xsl:call-template name="dvt_1.body">
				<xsl:with-param name="Rows" select="$Rows" />
				<xsl:with-param name="FirstRow" select="1" />
				<xsl:with-param name="LastRow" select="$RowLimit" />
			</xsl:call-template>
		</table>
	</xsl:template>
	<xsl:template name="dvt_1.body">
		<xsl:param name="Rows" />
		<xsl:param name="FirstRow" />
		<xsl:param name="LastRow" />
		<xsl:for-each select="$Rows">
			<xsl:variable name="dvt_KeepItemsTogether" select="false()" />
			<xsl:variable name="dvt_HideGroupDetail" select="false()" />
			<xsl:if test="(position() &gt;= $FirstRow and position() &lt;= $LastRow) or $dvt_KeepItemsTogether">
				<xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1">
					<xsl:call-template name="dvt_1.rowview" />
				</xsl:if>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="dvt_1.rowview">
		<tr>
			<td>
				<table border="0" cellspacing="0" width="100%">
					<tr>
						<td width="25%" class="ms-vb" rowspan="2">
					<img border="0" src="{@Thumbnail}" />
						</td>
						<td width="75%" class="ms-vb" height="5%">
						<a href="{substring-before(@Page_x002f_URL_x0020_to_x0020_li, ', ')}">
								<xsl:value-of select="substring-after(@Page_x002f_URL_x0020_to_x0020_li, ', ')" />
							</a></td>
					</tr>
					<tr>
						<td width="75%" class="ms-vb"><xsl:value-of select="@Highlights_x0020_Description" disable-output-escaping="yes" /></td>
						
					</tr>
					<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
						<tr>
							<td colspan="99" class="ms-vb">
								<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view" />
							</td>
						</tr>
					</xsl:if>
				</table>
			</td>
		</tr></xsl:template>
</xsl:stylesheet>	

Open in new window


I'm using SP2007
0
Comment
Question by:sharepoint2013
2 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38787908
Hi,
sorry to have just a link, but with that information you should be able to create the requested format:
http://stackoverflow.com/questions/9407507/how-to-get-a-xsl-to-display-results-in-multi-columns

HTH
Rainer
0
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst earned 500 total points
ID: 38797911
Hello,

see this question: http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/MS-SharePoint/Q_27877111.html

Explanation:
Add table row tags around the for-each loop that calls the rows, and after each 4th row add a closing and an opening tr tag. The latter must be done in escaped notation, otherwise, the thing will bomb.

XSL applied to your DVWP above (just the dvt_.body and dvt_1.rowview templates):

	<xsl:template name="dvt_1.body">
		<xsl:param name="Rows"/>
		<!-- start the first row of the table outside of the row loop -->
		<tr>
			<xsl:for-each select="$Rows">
				<xsl:call-template name="dvt_1.rowview" />
			</xsl:for-each>
		<!-- end the last row of the table -->
		</tr>
	</xsl:template>
	
	<xsl:template name="dvt_1.rowview">
			<td>
				<table border="0" cellspacing="0" width="100%">
					<tr>
						<td width="25%" class="ms-vb" rowspan="2">
					<img border="0" src="{@Thumbnail}" />
						</td>
						<td width="75%" class="ms-vb" height="5%">
						<a href="{substring-before(@Page_x002f_URL_x0020_to_x0020_li, ', ')}">
								<xsl:value-of select="substring-after(@Page_x002f_URL_x0020_to_x0020_li, ', ')" />
							</a></td>
					</tr>
					<tr>
						<td width="75%" class="ms-vb"><xsl:value-of select="@Highlights_x0020_Description" disable-output-escaping="yes" /></td>
						
					</tr>
					<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
						<tr>
							<td colspan="99" class="ms-vb">
								<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view" />
							</td>
						</tr>
					</xsl:if>
				</table>
			</td>
			<!-- after each 4th item, insert a closing tr tag and an opening tr tag for the next row -->
			<xsl:if test="position() mod 4 = 0">
				<xsl:text disable-output-escaping="yes">&lt;/tr&gt;</xsl:text>
				<xsl:text disable-output-escaping="yes">&lt;tr&gt;</xsl:text>
			</xsl:if>
	</xsl:template>

Open in new window


cheers, teylyn
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sharepoint 2010 Auditing 4 28
.net and XML report from SCCM 5 25
How to write an English digest paper 6 50
Sharepoint 2010 2 11
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question