1282 Posts in 355 Topics by 487 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 931 Views |
-
xml declaration and browsers

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?
<?php
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";
?> -
Re: xml declaration and browsers

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.
<?php
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";
else
return "what you need to return, if you dont want to return anything, just return false";
}
}?>
then add the following on your Page.ss on the relavant template, if it is BlackCandy do this on the /themes/blackcandy/templates/Page.ss
<% if AddCheck %>
$AddCheck
<% end_if %><!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" >..........
| 931 Views | ||
|
Page:
1
|
Go to Top |


