Stump the Panel » Site Managers and Site Collection Managers

How to add LinkUrl in XSLT in ListFormWebPart

(9 posts)
  1. I am hiding my default ListFormWebPart on my DispForm.aspx page so that I can hide the Target Audience field and change the RedirectUrl on the 'Close' buttons, however when I added my Custom List Form everything is looking great except I can't figure out how to link my 'Policy Names 2009' field (and 2008) back to their own detailed DispForm.aspx page. It is just giving me the policy names in plain text. The original ListFormWebPart has these links already instead of the plain text, but since the ListFormWebPart is unable to be exported I am unable to view the XSLT to see how they did it. Here is the relevant code for my Custom List Form:

    <xsl:template name="dvt_1.rowview">
    <tr>
    <td>
    <table border="0" cellspacing="0" width="100%">
    <tr>
    <td width="190px" valign="top" class="ms-formlabel">
    <H3 class="ms-standardheader">
    <nobr>Department Code</nobr>
    </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
    <xsl:value-of select="@Department_x0020_Code"/>
    </td>
    </tr>
    <tr>
    <td width="190px" valign="top" class="ms-formlabel">
    <H3 class="ms-standardheader">
    <nobr>Unit Code</nobr>
    </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
    <xsl:value-of select="@Unit_x0020_Code"/>
    </td>
    </tr>
    <tr>
    <td width="190px" valign="top" class="ms-formlabel">
    <H3 class="ms-standardheader">
    <nobr>Department Name</nobr>
    </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
    <xsl:value-of select="@Department_x0020_Name"/>
    </td>
    </tr>
    <tr>
    <td width="190px" valign="top" class="ms-formlabel">
    <H3 class="ms-standardheader">
    <nobr>Policy Names 2009</nobr>
    </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
    <xsl:value-of select="@Policy_x0020_Names_x0020_2009"/>
    </td>
    </tr>
    <tr>
    <td width="190px" valign="top" class="ms-formlabel">
    <H3 class="ms-standardheader">
    <nobr>Policy Names 2008</nobr>
    </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
    <xsl:value-of select="@Policy_x0020_Names_x0020_2008"/>
    </td>
    </tr>
    <!--<tr>
    <td width="190px" valign="top" class="ms-formlabel">
    <H3 class="ms-standardheader">
    <nobr>Target Audiences</nobr>
    </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
    <xsl:value-of select="@Audience"/>
    </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"></span>
    </td>
    </tr>
    </xsl:if>
    </table>
    </td>
    </tr>
    </xsl:template>

    Posted 3 weeks ago #
  2. I was working on some XSLT stuff last week to redirect some button clicks, here are a couple resources I found helpful:
    http://autosponge.spaces.live.com/blog/cns!D7F85948C20F0293!233.entry
    http://www.sharepointings.com/2008/07/29/custom-list-forms/

    Posted 3 weeks ago #
  3. Thanks Eric,

    I didn't phrase my question very well, but I have already found a solution for the redirect on the button. I just had to add the 'RedirectURL=""' attribute to the code of my SharePoint GoBackButton:

    <SharePoint:GoBackButton runat="server" ControlMode="Display" id="gobackbutton2" RedirectUrl="/sites/insurance/default.aspx"/>

    My problem is with one of the data fields:

    <tr>
    <td width="190px" valign="top" class="ms-formlabel">
    <H3 class="ms-standardheader">
    <nobr>Policy Names 2009</nobr>
    </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
    <xsl:value-of select="@Policy_x0020_Names_x0020_2009"/>
    </td>
    </tr>

    How do I use XSL to return a linked url data field for Policy Names 2009? Currently it just returns plain text. I need to be able to click on the field and go to its own DispForm.aspx page, which is what the default LFWP does already.

    Posted 3 weeks ago #
  4. David,

    Try adding disable-output-escaping="yes" to your xsl:value tag.

    Alternately, in Design view, click the chevron next to the data field and set Format as: to Rich Text. Does the same thing.

    Blessings,
    Jim Bob

    Posted 3 weeks ago #
  5. Hi Jim Bob,

    I tried setting the data field to Rich Text but that didn't change anything. I have been looking at some xsl in ItemStyle.xsl and it looks like I may need to get the OuterTemplate functions involved somehow? I have tried modifying my code to look something like this:

    <xsl:variable name="PolicyNameLink">
    <xsl:call-template name="OuterTemplate.GetTitle">
    <xsl:with-param name="Title" select="@Policy_x0020 _Names_x0020_2009"/>
    <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
    </xsl:call-template>
    </xsl:variable>
    <xsl:call-template
    name="OuterTemplate.CallPresenceStatusIconTemplate"/>
    <a href="{$SafeLinkUrl}" target="{$LinkTarget}"
    title="{@LinkToolTip}">
    <xsl:value-of select="$PolicyNameLink"/>

    But this breaks the web part, lol. Any ideas? Is the OuterTemplate idea worth pursuing? This XSL is going to be the death of me!

    Posted 3 weeks ago #
  6. Another option... change it to:

    <xsl:copy-of select="@Policy_x0020_Names_x0020_2009"/>

    Blessings,
    Jim Bob

    Posted 3 weeks ago #
  7. Okay thanks, I tried changing it to:

    <xsl:copy-of select="@Policy_x0020_Names_x0020_2009"/>

    but this returns no values to DispForm.aspx.

    Posted 3 weeks ago #
  8. AdamCarr
    Member

    What types are the columns are you are trying to link, as they sound like a lookup column if there default state is a hyperlink to another display form for the item.

    Posted 3 weeks ago #
  9. David,

    Have you tried using a SharePoint control?

    <SharePoint:FormField runat="server" id="ff5{$Pos}" controlmode="Display" fieldname="Policy_x0020_Names_x0020_2009" />

    ff5 is arbitrary, but must be unique to your page. You could actually replace the entire id with anything unique to your page.

    Blessings,
    Jim Bob

    Posted 2 days ago #

RSS feed for this topic

Reply

You must log in to post.