3

I have the following snippet in rules.xml

<!-- Fix 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.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
  • What's the meaning of "real URL"? Can't you use relative URIs? If you cannot and the information is not present in the input source, then you will need to pass as parameter. That configuration depends on the XSLT processor API. –  Apr 20 '11 at 21:53
  • Good question, +1. Seemy answer for an explanation and a complete example. – Dimitre Novatchev Apr 20 '11 at 22:08

2 Answers2

1

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.

optilude
  • 3,538
  • 3
  • 22
  • 25
0

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.

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431