Search

I'm having issues in an Images section trying to get {entry/@id} to output. It outputs nothing. I've also tried entry/@id to no avail. Using the extension on the default branch. Any suggestions?

A quick debug technique is to open the entry in your browser, then at line 141 of extension.driver.php, do a var_dump($dom->saveXML());die; to see if the entry is created properly.

So I'm just wanting it to output in the backend... how would I check in the frontend? I checked a datasource that was pulled from an images section and it does have the entry/@id structure.

Got it sorted. I guess I need to re-save the entries.

@jdsimcoe - use the Resave Entries extension... that will save you tons of time.

Nice!

Editing entries via the front end does not seem to update Reflection field.

As far as I can tell: Resave Entires uses an ajax method call to the preferences page to resave the section data so no it wont trigger a re-save from front end.

@Pat

You must include the field as well in the form. Eg:

<input name="fields[reflection-title]" type="hidden" value=""/>

@vladG: That worked perfectly!!

How do I get returned the actual Reflection field's (RF) value in RF's XSLT utility?

I already use an XSLT utility to customize RF's return value, but I can not get the actual or last known RF value into XSLT.

I have a RF with handle test and the XSLT utility is

...
<xsl:template match="data">
<data>
<test>
<xsl:value-of select="entry/test"/>
</test>
....

The RF expression is {test}.

It had a value before. With this test I am only trying to get the value.

The entry object is built for the xslt utility, and your xslt above is trying to get the value from the field you're trying to add the value to.

What is the actual field handle you're trying to get the value of?

Thanks designermonkey. I want to get the reflection field's value, so the one you said I try to add to.

The situation is, the reflection field does have (or shows) a value, e.g. XXX.

Now I changed its expression to the {test} to test out, if I can work with that value in the entry object build for the reflection.

I took chances the reflection field's former value would exist during that time. But probably its not exposed to the entry object.

It could be used to extend the possibilities of xslt evaluation, like keep the former value if "field X is Y".

I just tried it out and it looks like the Reflection field cannot refer to itself, but it can refer to another Reflection field.

You would get the same result by having one Reflection with a utility, then using another one to test the result.

@Pat, thanks, yes, it works like this (if the tested RF is before the testing RF in that section).

... the Reflection field cannot refer to itself...

Is this an API limitation, or just a filter in the RF extension? Because the value exists, if it was gained before. Maybe something could be easy added in here.

I think it would be usable to have the RF own value available in the generated XML, e.g. like there is entry/@id - the id of the entry itself. It would enrich the XSLT evaluation possibilities, e.g. to retain a value if desired, as mentioned here.

Actually, come to think of it, it might be there if the field previously has a value.

Try:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
        <value>
            <xsl:apply-templates select="data/entry"/>
        </value>
    </xsl:template>

    <xsl:template match="entry">
        <xsl:value-of select="test/text()"/>
    </xsl:template>
</xsl:stylesheet>

and then try a xPath value of: {value/text()}

OK, I tried, but it did not worked. RF value was set empty.

To confirm steps:

  1. I have a section with a text field title and a RF field test.
  2. At first, the RF's Expression is {entry/title} with no XSLT Utility set. It gets populated with title's value, e.g. "ABC".
  3. Next, I change RF's Expressionto {value/text()} and apply that XSLT Utility as told above. The test RF field gets no value.

It should retain the "ABC" value. Well I mean "it could". Thats what I'm after.

EDIT: Just a sec, want to check something... ok. no change. Cause I have a slightly changed RF extension that returns an array of values instead of a string, so I had to change the XSLT to test/item/text(), but I also tried the official RF version and no change. I want to introduce the array idea too (no big thing), but don't want to mix these two things together.

Thanks.

@juro - instead of matching the template to the root node, try to data like so...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="data">
        <value>
            <xsl:apply-templates select="entry"/>
        </value>
    </xsl:template>

    <xsl:template match="entry">
        <xsl:value-of select="test/text()"/>
    </xsl:template>
</xsl:stylesheet>

See if that works.

Thanks @bzerangue, also no change. to confirm, I used your template, and the RF expression was {value/text()}.

Actually I realized now, that I had to add a data root element to the template to actually get anything at all from the XSLT, as mentioned in this comment - dummy me, sorry, 'cause I already use it in another utility for this purpose - but also no change.

So I have now:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="data">
    <data>
        <value>
            <xsl:apply-templates select="entry"/>
            <xsl:text>aaa</xsl:text> <!-- just get anything -->
        </value>
    </data>
    </xsl:template>

    <xsl:template match="entry">
        <xsl:value-of select="test/text()"/>
        <xsl:text>bbb</xsl:text> <!-- just get anything -->
    </xsl:template>
</xsl:stylesheet>

I get only those "control" values ("bbbaaa"). Without a data root tag they weren't returned either.

Its about 1am here and I am leaving in the morning for a prolonged weekend, so I won't be able to answer few days, but many thanks for your ideas so far! C U next week and all the best!

Is it possible to generate html code with a xslt utility? I’m miserably failing, only the text part is in the output.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="data/entry">
  <data>
    <xsl:element name="person">
      <xsl:if test="bild/filename">
        <img src='{params[root]}/image/2/35/35/5{bild/@path}/{bild/filename}' />
      </xsl:if>
        <xsl:value-of select="vorname"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="nachname"/>
    </xsl:element>
  </data>
</xsl:template>


</xsl:stylesheet>

Expression is simply {person}

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