Skip to content

Improved field data output

rowan-lewis edited this page Jun 3, 2011 · 1 revision

In Symphony 2 Fields output their data in three ways, as XML from the appendFormattedElement function, as HTML from the prepareTableValue function, and finally sometimes the HTML is hacked into a plain text value.

Not having a reliable means to get a simple value out of a field is a problem.

Rowans proposal

Instead of doing things this way, I'd like to see these functions replaced with something that performs better. HTML output is no longer needed at all, since the XML output will be transformed into the appropriate HTML bu the fields XSLT stylesheets. So instead we need two functions, one for outputting XML and one for outputting plain text.

These functions won't follow the example set by appendFormattedElement in which the function receives an XMLElement and appends itself to that:

public function appendFormattedElement(XMLElement $wrapper, ...) {
	$element = new XMLElement($this->get('element_name'));
	$wrapper->appendChild($element);
}

Instead they will build an XMLElement themselves and simply return it.

See this gist for code.

Clone this wiki locally