Solved

SharePoint Dataview XSL Help

Posted on 2013-01-16
2
952 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:
teylyn 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now