2.0.4releasedReflection Field

This field generates values based on other fields from the same entry. Uses XPath and optionally XSLT.

Clone URLhttps://github.com/symphonists/reflectionfield.git

Add as a submodulegit submodule add https://github.com/symphonists/reflectionfield.git extensions/reflectionfield --recursive

Compatibility

2.x.x2.1.x2.2.x2.3.x2.4.x2.5.x2.6.x2.7.02.7.12.7.22.7.32.7.42.7.52.7.62.7.72.7.82.7.92.7.10
No1.0.91.2.02.0.42.0.42.0.42.0.42.0.42.0.42.0.42.0.42.0.42.0.42.0.42.0.42.0.42.0.42.0.4

Readme

Field: Reflection

This field generates values based on other fields from the same entry. Uses XPath and optionally XSLT.

Usage

When saving an entry Reflection field creates an internal data structure similar to what Symphony provides on the front-end. Besides the field data contextual parameters like the root and workspace paths and the section handle are available as well.

xml <data> <params> <today>2016-08-02</today> <current-time>12:34</current-time> <this-year>2016</this-year> <this-month>08</this-month> <this-day>02</this-day> <timezone>+02:00</timezone> <website-name>Example Website</website-name> <root>https://example.com</root> <workspace>https://example.com/workspace</workspace> <http-host>example.com</http-host> <upload-limit>5242880</upload-limit> <symphony-version>2.7.0</symphony-version> </params> <reflection-field-handle> <section id="…" handle="…">…</section> <entry id="…"> <field-one>…</field-one> <field-two> <item handle="…">…</item> <item handle="…">…</item> </field-two> <system-date> <created iso="…" timestamp="…" time="…" weekday="…" offset="…">…</created> <modified iso="…" timestamp="…" time="…" weekday="…" offset="…">…</modified> </system-date> </entry> </reflection-field-handle> </data>

Note: Version 2.0 changed the data structure to conform with the front-end. The root and workspace nodes moved to the parameter pool. The entry-id node was removed as the id was already available on the entry node.

XSLT Utilities

XSL templates are used to manipulate the XML data before building the reflection expression. Any template in /workspace/utilities can be attached to the field: it will be provided with the above XML. The extension expects you to return an XML structure again, that is then used inside the expression field.

Expressions

Expressions are used to build the field's content. You can add static content or markup, dynamic values can be added using curly braces containing xPath expressions to find the needed data. If you don't use an XSLT utility, the xPath expression is evaluated against the above XML. If you transformed the source data using a template, the xPath is evaluated against the returned XML structure you created.

Note: Version 2.0 also changed the way xPath expressions are processed and introduced some bugs and irritation regarding what kind of expressions were supposed to work – since release 2.0.4 all valid xPath expressions can be used. See this comparison-chart for detailed information and test results.

Usage with XML Importer

Reflection Field assumes that the entry has already saved some data for the said field, and then seeks to update the database directly with the correct reflection generated content. In the case of XML Importer this means that you have to include the Reflection field within the import items, otherwise XML Importer will not find any data within your database to update. You can insert an empty string, this would be sufficient for Reflection Field to be able to save the necessary data.

Version history

Symphony 2.3 to 2.x.x

  • Fix XPath-expressions #35

Symphony 2.3 to 2.x.x

  • Fix field caption and thus 1.D in #35

Symphony 2.3 to 2.x.x

  • Fix issues with xslt functions

Symphony 2.3 to 2.x.x

  • PHP 7 compatibility

Symphony 2.3 to 2.x.x

  • Added reflection field handle to param node
  • Moved root and workspace nodes to param node to conform with the front-end XML structure
  • Added XSLT utility instructions

Symphony 2.3 to 2.6.x

  • Prevent the same field from being registered multiple times
  • Added XML Importer instructions

Requires Symphony 2.3

  • Added XML Importer support
  • Added system date to generated entry XML

Requires Symphony 2.3

  • Added export modes

Requires Symphony 2.3

  • Allow reflection field to recalculate data when field is toggled from publish indexes
  • Fix issue when an installation has no Utilities

Requires Symphony 2.3

  • Made compatible with Symphony 2.3

Symphony 2.2 to 2.3

Requires Symphony 2.2

  • Force tables to be created with the MyISAM table engine.

Requires Symphony 2.2

  • Fixed a sanitisation issue on publish pages.
  • Made compatible with Symphony 2.2.

Requires Symphony 2.1.x

  • Bug with usage of appendFormattedElement fixed by michael-e.

Requires Symphony 2.1.x

  • Some bug fixes and code cleanup.

Requires Symphony 2.1.x

  • Fixed column sorting issues.
  • Added more filter modes.

Requires Symphony 2.1.x

  • Added a search: filter method to allow you to use boolean type searching.

Requires Symphony 2.1.x

  • Fixed a number of possible encoding issues.