I have the following snippet in rules.xml
<!-- Fi开发者_Go百科x search box to honour Plone rules-->
<replace css:theme="form#search">
<form action="http://localhost:8080/LS/search" name="form1" id="search">
<input type="text" name="SearchableText" onclick="make_blank();" onblur="keep_search();" class="search_text_style content_text2"/>
<input type="image" src="++resource++lsm/images/template/search.png" width="22" height="22" class="search_btn" />
</form>
</replace>
How one can pass dynamic attributes to XSL so that I cat set to be real URL based on the Plone site object?
I can do this by providing helper views, modify XDVTransform, etc. but I'd like to first know what's the recommended approach here.
Note that in plone.app.theming / Diazo, you'll be able to define parameters using TAL and pass them to your theme.
I think in this case, I'd just grab the actual search URL (or the home URL) from the content with an attribute value-of.
I think you need a global <xsl:param>
for this.
Typically, the value of a global parameter is set by the initiator of the transformation just before the transformation is initiated. This is a recognized general way of passing to the XSLT transformation values that are not static (known at the stylesheet compilation time).
Here is an example:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="pUrl" select="'http://www.cnn.com'"/>
<xsl:template match="/">
<t href="{$pUrl}"/>
</xsl:template>
</xsl:stylesheet>
when this transformation is applied on any XML document (not used), the result is:
<t href="http://www.cnn.com" />
How a global parameter value is set is implementation-dependent and varies from one XSLT processor to another. Read the documentation of your XSLT processor to get the knowledge how to do this.
精彩评论