2
votes

I have a section called Products where every product is defined by Text Input and Multilingual Text Box. I have created over 100 products with custom description. At some point I need to place current year in Multilingual Text Box:

Lorem ipsum dolor <xsl:value-of select="$this-year" /> ipsum <a href="{$root}">Link to root</a>

which gives:

'Long Description' contains invalid XML. The following error was returned: loadXML(): Namespace prefix xsl on value-of is not defined in Entity

or I want to print data from Data Source:

Lorem ipsum
<xsl:variable name="products" select="/data/products" />
<xsl:for-each select="$products">
    //... do other XSL stuff in XML
</xsl:for-each>

which of course will cause error too.

Please take in account that I am total beginner in Symphony/XSLT and some of conceptions are still not well understood by me.

1
XSL, typically, is used to transform an already-created XML document (referred to as XSLT, typically). You may want to read up on the basics of that. w3schools.com/xsl/xsl_languages.aspCody S
That's quite sad till as I know Symphony doesn't provide any other reasonable way to create complex entries with referring to site content (variables, data sources, etc.) in admin panel. Can we really could call Symphony a CMS?joe.kovalski
No clue. Never heard of Symphony. I'm a Java software engineer that happens to have a bit of background with XSLT, and, based on your code above (and not trying to be rude here), it looks like you are doing it wrong. Just wanted to let you know. Perhaps somebody with more experience with Symphony or other CMS tools can help more.Cody S
Thanks anyway, I must be missing something obvious here.joe.kovalski

1 Answers

1
votes

Symphony community helped me with this subject, so let me just quote jonmifsud:

The easiest way to do that would be using what’s called the XSLT ninja technique. Simplest way (...) would be to create html tags which are to be replaced. For example we can ask him to input <this-year/> in the text where you want this year variable to appear which means when you output text you are using <xsl:apply-template select=‘your-text’ mode=‘html'/>. Now the trick with the XSLT would be the following: you will need to match the new “tag” you created for your variable and replace it with the values you want

Example

<xsl:template match="this-year" mode="html">
    <xsl:value-of select="/data/params/this-year">
</xsl:template>

<xsl:template match="*" mode="html">
    <xsl:element name="{name()}">
        <xsl:apply-templates select="* | @* | text()" mode="html"/>
    </xsl:element>
</xsl:template>

<xsl:template match="@*" mode="html">
    <xsl:attribute name="{name()}">
        <xsl:value-of select="."/>
    </xsl:attribute>
</xsl:template>

This approach is nearly limitless.