Search

Only text, no html.

Argh!

Thanks Vlad!

the problem you have there is you're generating real html, not a string of html. Try wrapping it in CDATA tags?

Or try like the top answer here: http://stackoverflow.com/questions/6696382/xslt-how-to-convert-xml-node-to-string

@designermonkey ah, good! Will try that tomorrow. Cheers.

CDATA did the trick, brill! Thanks John!

:)

Hi, I am stucked in a reflection challenge: I have an entry with:
- a textarea called "code" where you can type html code
- a reflection field where I want to store all elements names, coma separated

Here is my utility to extract all tag names:

   <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="data">
         <data>
            <xsl:element name="code-elements">
               <xsl:for-each select="code/*">
                  <xsl:value-of select="local-name()"/>,
               </xsl:for-each>
            </xsl:element>
         </data>
      </xsl:template>
   </xsl:stylesheet>

The result is nothing (tried with name() instead of local-name() too), I suppose that the textarea is wrapped in a cdata, reason why I cannot get the element names as if it was a xml node. So I tried to consider "code" as a string and extract elements names with the substring-before(substring-after($string,'</'),'>') method. This way always result in errors because < and > are not allowed, even wrapped into a <xsl:variable><xsl:text>.

Any idea about how to make it works?

@vincentd, a quick thought:

  1. Try to apply a text formatter onto your textarea to preserve the markup, not sure which one of the existing can do that the clearest way, but I've tried Markdown with html tags some time ago and it worked,
  2. Maybe XML Field extension could also do the trick too, but haven't tried out.

And maybe one more: Maybe you could go without the reflection and parse what you need from the textarea with a XSLT sheet on page view? Could be also more speedy, that is leaving out a field from the datasource. But I don't know your aim, so otherwise don't mind.

The markup is not valid so I can't do it this way ;-)
I got it using recursively substring-before(substring-after($string,'</'),'>') it needs to be defined this way: substring-before(substring-after($string,'&lt;/'),'&gt;') it s finally easy.

I am now in the same situation as Juro on the previous page:
I need a field value that is stored/reflected once then "stays static".

The purpose is a shop-order which stores the price of the article at the time of the order, not the live value of price.

Any ideas?

You can have a dedicated section storing the orders, without reflection field.

Yes - that is already fixed.

The problem is when the shop-owner manually adds an order through the backend.
The fields must be filled with current product-values, but also they can be changed anytime.

The filled fields are a snapshot/copy of the item at the time of creation.
It's no problem doing this from frontend, but... the backend. how?

You can use a remote select box combined with a reflection field. Remote select box will need to be filled from a json of your front end. This is the only way I see to do this in back end.

But I feel it s a lot of pain for a little added value, and if the Administrator resave an entry it could change the value of the price and mess up with the invoices, accounting taxes... So I would recommend a simple input field for this specific use case, in a section populated from a front end form, accessible only to logged in administrators.

My two cents.

Thank you vincentd.

After all, I think I will solve it with some javascripts.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details