Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

$content.FirstParagraph can't handle &


Go to End


3 Posts   1401 Views

Avatar
gmfallon

Community Member, 2 Posts

3 July 2011 at 8:55pm

I'm trying to switch themes from blackcandy to natureweb4 and by doing so I get an error message when $content.FirstParagraph encounters an & -

error on line 86 at column 32: xmlParseEntityRef: no name

I searched the archives and found http://silverstripe.org/archive/show/2146 but the page referenced seemed to be addressing a different problem. Anyway, once I remove the "&" the error goes away.

Avatar
(deleted)

Community Member, 473 Posts

3 July 2011 at 9:36pm

This is because your template is an XML rather than HTML one. You can change this my removing the <?xml ?> line at the start of templates/Page.ss.

Alternatively, $Content.FirstParagraph.XML may escape the & properly, though it may also escape things you don't want escaped, like brackets on tags.

Avatar
gmfallon

Community Member, 2 Posts

4 July 2011 at 7:53am

Excellent - thanks Simon! Removing <?xml ?> fixed it.