Search

I'm using the "ninja technique" to detect if the user has posted a link with their comment like so:

<xsl:template match="comment//p[starts-with(., 'http://')]">
    <p><a href="{.}"><xsl:value-of select="."/></a></p>
</xsl:template>

This obviously has some issues. If someone has any inline text before or after the url, it won't work right or it won't select the link at all. I know I can use contains() instead of starts-with(), but that still selects the whole <p> node..

Is there a way to target just the link/url from inside the paragraph node?

Thanks

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details