3215 Posts in 848 Topics by 811 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 245 Views |
-
Escaping < in templates

1 March 2012 at 12:18am Last edited: 1 March 2012 12:19am
I'm outputing an XML file for excel which requires second line:
<?mso-application progid="Excel.Sheet"?>
I've looked around for a couple of hours but can't find a reference to the escape character for "<" and ">" in the templates, to stop silverstripe converting it to:
SSVIEWER;
mso-application progid="Excel.Sheet";
$val .= <<<SSVIEWERCan somebody let me know the correct method of displaying the line literally?
-
Re: Escaping < in templates

1 March 2012 at 3:35am
I've gone with an alternative solution to my problem for now. I've gone into the SSViewer.php code in sapphire/core and added some lines to the parsing code. The code treats the xml header beginning "<?xml" as a special case and I've added lines to do the same to my "<?mso-application" lines.
$content = ereg_replace('<\?xml([^>]+)\?' . '>', '<##xml\\1##>', $content);
$content = ereg_replace('<\?mso-application([^>]+)\?' . '>', '<##mso-application\\1##>', $content);$output = ereg_replace('<##xml([^>]+)##>', '<' . '?xml\\1?' . '>', $output);
$output = ereg_replace('<##mso-application([^>]+)##>', '<' . '?mso-application\\1?' . '>', $output);It does work, but I don't like playing with the core code like this. If somebody can suggest an alternative solution, such as a way of escaping my '<' or '?' characters to print my mso-application line, it would be a big help.
| 245 Views | ||
|
Page:
1
|
Go to Top |

