marți, august 07, 2007

A Better HREF handing

After converting a list to XSLT dataview, I am having some problem with URLs inl lists, so I make it a little easy to use for editing XSLT.

To make this work, create a new list, and give it a fieldname of URL which is a link (href) type list object.

Here is a much better way to encode the a href tags:


<xsl:variable name="ThisURL" select="substring-before(@URL, ', ')" />
<xsl:variable name="ThisTitle" select="substring-after(@URL, ', ')" />
<xsl:if test="normalize-space($ThisTitle)!=''">
<div class="ms-vb2">
<A HREF="{$ThisURL}" title="{$ThisTitle}"><xsl:value-of select="$ThisTitle" /></A>
</div>
</xsl:if>


If you name the field something else like 'mylink' or something, just replace @URL in the code above with your fieldname.

Hope that help you.

Niciun comentariu:

Despre mine

Timi-Ostravia, Republic of Czedvia, Bulgaria
I make web applications. The tools I use are many and far between. I have been maining to learn Ruby and Python, and Perl. These tools are all like Lego to me. They can all be make to build things and have their strengths and weakest.