Quantcast
Channel: Planet Plone - Where Developers And Integrators Write
Viewing all articles
Browse latest Browse all 3535

Izak Burger: Using XSLT to shorten some links

$
0
0

When plone uses resolveuid and relative linking, the link can often be much shorter

This is not a long post. Its just something we had to do this morning, something that was necessary because some software on the windows platform has trouble with very long urls.

We noticed that the majority of urls on the site ends in resolveuid/someuid, but that they are very long because the folder structure is both deeply nested and have long and descriptive names. What we wanted to do is to shorten them simply to /resolveuid/someuid. But we didn't want to modify the content, because it would just break again the next time its opened in TinyMCE.

The solution is simple, because we were already using xdv.

<xsl:template match="@href[starts-with(., 'resolveuid/') or contains(., '/resolveuid/')]">
  <xsl:attribute name="href">/resolveuid/<xsl:value-of select="substring-after(., 'resolveuid/')" /></xsl:attribute>
</xsl:template>

This has to be placed in your rules file directly inside the <rules> tag. You cannot place it in any file that is included using xinclude, as I wanted to do, that does not work. It does now work because xincluded rules end up in nested <rules> tags, and the xsl stylesheet that generates the final stylesheet only looks for inline xsl in xdv:rules/xsl:*, that is, the topmost level.


Viewing all articles
Browse latest Browse all 3535

Trending Articles