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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Themes /

Discuss SilverStripe Themes.

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

xml declaration and browsers

Go to End

2 Posts   1581 Views


Community Member, 2 Posts

15 January 2009 at 4:15pm

Hi all,
new to the world of SilverStripe, though I'd have to say I'm liking what I'm seeing to date. That said, I'm discovering very quickly that one of my favourite methods of ensuring xml doctype is present where it should be won't work and am looking for a workaround.

Normally, at the top of my file I'll add this for PHP applications (I have a similar check of Rails apps). So my question is, what would be my step for how I would be able to do something like this?

	if(!preg_match('/MSIE\s(6\.0|5\.5|5\.0|5\.23);\s(Windows|Mac)/i', $_SERVER['HTTP_USER_AGENT'], $match))
		echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";


Community Member, 400 Posts

15 January 2009 at 5:22pm

This can be accomplished by adding a method to the Page_Controller class.

edit your mysite/code/Page.php like the following.


class Page extends SiteTree {


class Page_Controller extends ContentController {
	function init() {
	function AddCheck() {
		if(!preg_match('/MSIE\s(6\.0|5\.5|5\.0|5\.23);\s(Windows|Mac)/i', $_SERVER['HTTP_USER_AGENT'], $match))
                   return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; 
                   return "what you need to return, if you dont want to return anything, just return false";


then add the following on your on the relavant template, if it is BlackCandy do this on the /themes/blackcandy/templates/

<% if AddCheck %>
<% end_if %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="" xml:lang="en" >