Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and ListCorrect Way to Decode URL stored in "Download" field in XSL?Correct Way to Decode URL stored in "Download" field in XSL?
Previous
 
Next
New Post
1/27/2016 2:55 PM
 

I have a field in a F&L called "PDF", which is a Download type. As a result, I have the following tokens to play with in XSL:

[PDF]
[PDF_UDT_Url]
[PDF_UDT_Caption]
[PDF_UDT_Original]

I'm trying to build my own href anchor using [PDF_UDT_Url], but no matter what I do, it always displays with escaped ampersands (& instead of simply &).

I've tried directly referencing the field as:

   <a href="{$PDF_UDT_Url}">My Link</a>

And I've tried creating a new xsl:param, assigning the value of PDF_UDT_Url to it, and then using the param, both with disable-output-escaping attribute to "yes" (neither "yes" nor "no" seem to affect it one way or the other):

    <xsl:param name="EncodedLink">

      <xsl:value-of select="udt:PDF_UDT_Url" disable-output-escaping="yes" />

    </xsl:param>

    <a href="{$EncodedLink}" target="_blank">My Link</a>

I feel like I'm not even close to the correct approach. 

What is the correct way to reference the non-escaped full path to a field of type "Download" in XSL, when attempting to build your own hrefs?

 

 
New Post
1/28/2016 3:55 PM
 

Follow-up:

A key part of this mystery is something I just now noticed. When viewing the source HTML to the auto-generated link+caption, stored (by default) in the base field name (in this, in the [PDF] field), it reveals:

<a href="/LinkClick.aspx?fileticket=K3UEQbTGsA0%3d&amp;tabid=2373&amp;portalid=4&amp;mid=12900"  target="_blank">pt1187.pdf</a>

By default, this URL is *already* being encoded (incorrectly!), so it is no wonder that when it comes time to to manually build an href using [PDF_UDT_Url], the output is double-encoded:

<a href="/LinkClick.aspx?fileticket=K3UEQbTGsA0%3d&amp;amp;tabid=2373&amp;amp;portalid=4&amp;amp;mid=12900">Click Me</a>

Is this a bug in "Forms & List"? Or have a made a decision somewhere in the configuration of this list/field type that is making it behave as such?
 
New Post
1/31/2016 1:40 PM
 
Hi Ken,
I don't exactly know what you wanted to show on your page after the XSLT transformation. Anyways, you would have to take note that the a-tag HREF attribute will NOT process the 'disable-output-escaping="yes|no"'. In your case the following would be the same. In all these cases, including your original post, the hyperlink "My Link" is a valid link that would open/download your [PDF_UDT_Url].

Your original post:
<xsl:param name="EncodedLink">
  <xsl:value-of select="udt:PDF_UDT_Url" disable-output-escaping="yes" />
</xsl:param>
<a href="{$EncodedLink}" target="_blank">My Link</a>

Equivalent:
<a href="{$EncodedLink}" target="_blank">My Link</a>
OR
<a>
    <xsl:attribute name="href">
        <xsl:value-of select="$EncodedLink"/>
    </xsl:attribute>
    My Link
</a>
OR
<a>
    <xsl:attribute name="href">
        <xsl:value-of select="$EncodedLink" disable-output-escaping="yes" />
    </xsl:attribute>
    My Link
</a>
OR
<xsl:element name="a">
    <xsl:attribute name="href">
        <xsl:value-of select="$EncodedLink"/>
    </xsl:attribute>
    My Link
</xsl:element>
<xsl:element name="a">
    <xsl:attribute name="href">
        <xsl:value-of select="$EncodedLink" disable-output-escaping="yes" />
    </xsl:attribute>
    My Link
</xsl:element>

On your follow-up post, I understand them as they are HTML encoded properly. Try the following and you'll see the difference. Then, compare them by viewing the page source. You can even copy the "/LinkClick.aspx?fileticket=..." and paste it in your browser to test if the links are really valid.
<div><xsl:value-of select="udt:PDF" disable-output-escaping="yes" /></div>
<div><xsl:value-of select="udt:PDF_UDT_Url" disable-output-escaping="yes" /></div>
<div><xsl:value-of select="$EncodedLink" /></div>
<div><xsl:value-of select="$EncodedLink" disable-output-escaping="yes" /></div>
<div><xsl:copy-of select="$EncodedLink" /></div>

If you just wanted to simply force the download to open in new window, you can use tick the 'Enable "Open in new window"' and 'Enforce Download' under List Settings of the the Field Editor. Optional: type in a static text like your "My Link" in the "Link Caption" of the same List Settings.

Finally, a not so beautiful option would be below:
<xsl:text disable-output-escaping="yes">&lt;a href="</xsl:text>
<xsl:value-of select="$EncodedLink" disable-output-escaping="yes" />
<xsl:text disable-output-escaping="yes">" &gt;My Link&lt;/a&gt;</xsl:text>

Hope this helps and I made sense...
Olan
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForm and ListForm and ListCorrect Way to Decode URL stored in "Download" field in XSL?Correct Way to Decode URL stored in "Download" field in XSL?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out