Search

EDIT: I've deleted the attachment here because Rowan's more powerful version is available below. I've also adjusted the text here so there's no confusion as to how the Reflection Field works

This is an input field whose value is auto-calculated, upon saving, according to a user-specified formula that can draw on the values of other fields.

For example, an Introspection (now Reflection) Field labeled "Full Name" with a formula of {entry/first-name} {entry/last-name} will autopopulate with the value of the field labeled "First Name" followed by a space followed by the value of the field labeled "Last Name." Pretty straightforward I guess.

NOTES

  1. A lot depends on the field names provided in the formula matching your actual field names, so be careful with that.
  2. If you ever change the formula for an instance of the field, you'll have to re-save every entry to recalculate the field's value.

Nice one czheng. I'm sure many will find use for this.

I've come up with an alternative implementation that I'll call a 'Reflection Field', basically it works in the same way as czhengs, but instead of using the post data to get information about it's related fields, mine uses the resulting XML.

This obviously results in a little more overhead, but not enough to cause any problems, but it gives you the advantage of being able to access the entry like you would from the frontend.

Anyhow, as for the notes on czhends extension, all points except #1 are true for mine: Instead of hiding the field, it appears as a disabled input box so you can see the value when editing a page.

You can find a copy on github.

If you change the value of the fields that it gets data from, does the value of this "reflection" or "introspection" field change as well?

Yeah, it does. Whenever the entry is saved the field is re-calculated.

Just wanted to thank you guys for this extension. Works great in conjunction with Select Box Link extension, allowing one to create a more descriptive field as the link.

Indeed the combination with the Select Box Link extension is great.

But: I noticed a massive performance problem with this combination. Data source execution time is approximately five times as high, compared to a select box link field with a "normal" field.

Is this unavoidable?

How thoroughly have you tested it? It strikes me as strange because, AFAIK, there isn't anything different happening during datasource execution... Rowan, is that correct?

I guess it's possible, the field needs a little work now, since I had to use a hack to grab the entry data, which is now a lot simpler to do thanks to changes to Symphony.

Well, I have tested it on a S 2.0.1 installation. By "five times as high" I really mean "at least five times as high". Changing the DS output from "normal field" to "reflection field" clearly showed the difference. It was a section with about 50 entries, not very much indeed.

I will try and update this website to 2.0.2. I am looking forward to a new version of this extension!

How exactly are you using this? I did some testing but found no issues with performance.

See this 'official' topic for further discussion.

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