Ashish Madkaikar
Ashish Madkaikar

Reputation: 129

Modifying XSL in xsltlistviewwebpart to render SharePoint 2010 ListItems as <ul> and <li> instead of <Table><tr><td>

I am trying to achieve what is mentioned in the title, but having trouble, need help. I am modifying the following templates

1. <xsl:template name="View_Default_RootTemplate" mode="RootTemplate" match="View" ddwrt:dvt_mode="root" ddwrt:ghost="hide">

2. <xsl:template match="View" mode="full" ddwrt:ghost="hide">

3. <xsl:template mode="Item" match="Row" ddwrt:ghost="hide">

Q-1 Should i be modifying any other templates?

Desired end result - To render a recursive view and each list item as <li>listitem...</li> surrounded by a top level <ul>
Q-2 when i change the <table> elements to <ul> and <tr> to <li> the final page is still rendered with tables which i don't see in the templates and the <ul> & <li> changes are inserted into some unknown <td>, the questions are a. What is the right way to do this? and what template is applied in this case?

Upvotes: 0

Views: 2784

Answers (1)

Scott Hatcher
Scott Hatcher

Reputation: 11

Here's a simple example that should take care of it for you. You really only need the following two templates:

<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="Main"/>
</xsl:template>

<xsl:template name="Main">
    <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
    <ul>
        <xsl:for-each select="$Rows">
            <li>
                <xsl:value-of select="@Title"/>
            </li>
        </xsl:for-each>
    </ul>
</xsl:template>

Upvotes: 1

Related Questions