Solved

SharePoint Dataview XSL Help

Posted on 2013-01-16
2
1,017 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 (Microsoft MVP / EE MVE) 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

726 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