481 Posts in 150 Topics by 238 members
| Go to End | Next > | |
| Author | Topic: | 2551 Views |
-
Can't Use & Symbol?

27 January 2009 at 1:40am
If I put the & symbol into the content of an article page, the system freaks out (v2.2.3). This is what I get:
XML Parsing Error: not well-formed
Location: http://www.unclebubby.com/wavs2/action-adventure/
Line Number 248, Column 43: <li class="newsSummary">In a dystopic & crime ridden Detroit, a terminally wounded
---------------------------------------------------------------^
I case it doesn't line up right, the ^ is pointing to the & symbol. Why does it care what's in my text field? -
Re: Can't Use & Symbol?

27 January 2009 at 4:00am
It doesn't care but '&' isnt valid xhtml/xml so what you need to do is add .XML to your variable in the template. (Assuming you use something like Summary...
Another option is to remove the xml prolog from the top of your Page.ss template, because it'll probably get broken again.
What's happening here is that the page is rendering invalid xhtml in a strict xml page, it's not really related to the system.
-
Re: Can't Use & Symbol?

27 January 2009 at 8:42am
& is invalid xhtml. Instead you can replace it with & This is the ascii character code for &.
-
Re: Can't Use & Symbol?

27 January 2009 at 8:45am
@JasonS Normally you don't need to do this yourself for the stuff you put in a HtmlEditorField.
-
Re: Can't Use & Symbol?

27 January 2009 at 9:26am
As more clarification, it works fine in the title field but freaks out if it's in the content field. I get that it's invalid XML, I just don't get why it's an issue coming out of a text field that it should only be interpreting as HTML, not XML, right?
@dio5 - My template is straight out of the tutorials. Where, specifically, would I need to make changes?
@JasonS - The code behind the field actually uses &
<p align="center"> In a dystopic & crime ridden Detroit, ...
The workaround is to spell it out, obviously.
-
Re: Can't Use & Symbol?

27 January 2009 at 9:32am Last edited: 27 January 2009 9:33am
Just had a look at http://www.unclebubby.com/wavs2/action-adventure/ - saw you replaced it with 'and'.
I don't know what's in the tutorials, so if you could show us yr template code? It's probably the method you use on the holder page to display just a part of the text that's causing it. But if the source code of that page shows & as well?!
-
Re: Can't Use & Symbol?

27 January 2009 at 10:22am
Main Page.ss
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" >
<head>
<% base_tag %>
$MetaTags
<link rel="stylesheet" type="text/css" href="mysite/css/layout.css" />
<link rel="stylesheet" type="text/css" href="mysite/css/typography.css" />
<link rel="stylesheet" type="text/css" href="mysite/css/form.css" />
</head>
<body>
<div id="Main">
<ul id="Menu1">
<% control Menu(1) %>
<li class="$LinkingMode"><a href="$Link" title="Go to the "{$Title}" page">$MenuTitle</a></li>
<% end_control %>
</ul>
<div id="Header">
$SearchForm
<h1>$Title</h1>
</div>
<div id="ContentContainer">
$Layout
</div>
<div id="Footer">
<span>Visit <a href="http://www.silverstripe.com" title="Visit www.silverstripe.com">www.silverstripe.com</a> to download the CMS</span>
</div>
</div>
$SilverStripeNavigator
</body>
</html>
ArticleHolder.ss<% include Menu2 %>
<div id="Content" class="typography">
$Content
<ul id="NewsList">
<% control Children %>
<li class="newsDateTitleSmall"><a href="$Link" title="Read more on "{$Title}"">$Title</a></li>
<li class="newsDateTitleSmall">Released in $Date.Year</li>
<li class="newsSummary">$Content.FirstParagraph <a href="$Link" title="Read more on "{$Title}"">Read more >></a></li>
<% end_control %>
</ul>
<center>For more information about any of the movies, shows or actors you see here,
<br>visit <a href="http://www.imdb.com" target="_blank">The Internet Movie Database (IMDB)</a>
<br><strong><a href="mailto:jfuscoDELETETHECAPS@gmail.com?subject=Wav Archive Feedback">Click here to send email to Uncle Bubby</a></strong></center>
</div>
ArticleHolder.php<?php
/**
* Defines the ArticleHolder page type
*/
class ArticleHolder extends Page {
static $db = array(
);
static $has_one = array(
);
static $icon = "tutorial/images/treeicons/news";
static $allowed_children = array('ArticlePage');
}class ArticleHolder_Controller extends Page_Controller {
function rss() {
$rss = new RSSFeed($this->Children(), $this->Link(), "The coolest news around");
$rss->outputToBrowser();
}
function init() {
RSSFeed::linkToFeed($this->Link() . "rss");
parent::init();
}}?>
-
Re: Can't Use & Symbol?

27 January 2009 at 10:39am Last edited: 27 January 2009 10:41am
Right,
what if you replace
$Content.FirstParagraph
with
$Content.FirstParagraph.XML
in ArticleHolder.ss
| 2551 Views | ||
| Go to Top | Next > |


