Last active
August 29, 2015 14:02
-
-
Save djoo/9cee1e958b62be8ca9fd to your computer and use it in GitHub Desktop.
eZ Publish 5 Add "onclick" attribute to "link" element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[link] | |
CustomAttributes[] | |
CustomAttributes[]=onclick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ezpublish: | |
system: | |
my_siteaccess: | |
fieldtypes: | |
ezxml: | |
custom_tags: | |
- { path: %kernel.root_dir%/../src/Djoo/BaseBundle/Resources/xsl/link.xsl, priority: 10 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet | |
version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/" | |
xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/" | |
xmlns:image="http://ez.no/namespaces/ezpublish3/image/" | |
exclude-result-prefixes="xhtml custom image"> | |
<!-- Original template transforms into <b> --> | |
<xsl:template match="link"> | |
<a> | |
<xsl:attribute name="href"> | |
<xsl:value-of select="@url"/> | |
</xsl:attribute> | |
<xsl:attribute name="target"> | |
<xsl:choose> | |
<xsl:when test="@target"> | |
<xsl:value-of select="@target"/> | |
</xsl:when> | |
<xsl:otherwise>_self</xsl:otherwise> | |
</xsl:choose> | |
</xsl:attribute> | |
<xsl:if test="@xhtml:title"> | |
<xsl:attribute name="title"> | |
<xsl:value-of select="@xhtml:title"/> | |
</xsl:attribute> | |
</xsl:if> | |
<xsl:if test="@custom:onclick"> | |
<xsl:attribute name="onclick"> | |
<xsl:value-of select="@custom:onclick"/> | |
</xsl:attribute> | |
</xsl:if> | |
<xsl:copy-of select="@class"/> | |
<xsl:apply-templates/> | |
</a> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment