6 users online. Create an account or sign in to join them.Users
Using one page with lots of xsl:params, a good idea?
This is an open discussion with 7 replies, filed under XSLT.
Search
Woo hoo! After about twenty attempts I finally got my code to show up properly. I can't get my head around Markdown.
No need to write actual HTML to output your code. Simply append at the beginning of each line 4 spaces or a tab character to turn it into a code block.
If you want to output inline code, you can do so by wrapping the code in question with back ticks (`).
Tried that, didn't work unfortunately. Couldn't work out why so gave up in the end.
I've edited your thread using the Markdown code formatting syntax. Check your thread out and see if that clears anything up for you.
With the line, <xsl:with-param name="extended" select="true"/>. I assume you want to pass in the value true to $extended. If this is the case, the line should read:
<xsl:with-param name="extended" select="'true'"/>
Notice the single quotes around true. Without single quotes, you are asking XSLT to assign the content inside the node <true> to $extended.
Have you considered using modes with your template?
<xsl:apply-templates select="products" mode="extended">
and
<xsl:template match="products" mode="extended">
...
</xsl:template>
Regarding the Markdown issue, I think the problem was that I did not leave a blank line between the paragraph and the code block.
Like this.
I'll try using modes, that's a good idea. Still concerned about the number of data sources though, perhaps unnecessarily.
Thanks!
I don't think you necessarily need another step to pass your products template down to the entry. You can simply try this:
<xsl:apply-templates select="products/entry">
<xsl:with-param name="extended" select="'true'" />
</xsl:apply-templates>
Create an account or sign in to comment.
I'm trying to build a site with the following structure:
At the moment I'm doing this using an
xsl:choose:<xsl:choose> <xsl:when test="$entry"> <xsl:apply-templates select="products"> <xsl:with-param name="extended" select="true"/> </xsl:apply-templates> </xsl:when> <xsl:when test="$cat"> <xsl:apply-templates select="products"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="categories"> <xsl:with-param name="use-images">yes</xsl:with-param> </xsl:apply-templates> </xsl:otherwise> </xsl:choose>So I'm passing a few parameters around to get the desired behaviour. In my products template I then pass the parameter down another level:
<xsl:template match="products"> <xsl:apply-templates select="entry"> <xsl:with-param name="extended" select="$extended"/> </xsl:apply-templates> </xsl:template>This seems a little complex and I've reached the point where I'm wondering if I'm doing the right thing. I've got several data sources:
$ds-current-categoryto the ID of the current category if$catis set$ds-current-category)I think I'll need another data source to get the current product if $entry is set. That's quite a few data sources, often unused.
Does anyone have any opinions on this approach? Am I going mad?!
The alternative approach that I am thinking of is as follows:
In other words I would have two more pages with 'c' and 'p' handles to simply the XSL and data sources.
Thoughts would be appreciated!