Jump to:

1384 Posts in 493 Topics by 522 members


SilverStripe Forums » Themes » xml declaration and browsers

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 1058 Views
  • jufemaiz
    Community Member
    2 Posts

    xml declaration and browsers Link to this post

    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";

  • Nivanka
    Community Member
    395 Posts

    Re: xml declaration and browsers Link to this post

    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 Page.ss on the relavant template, if it is BlackCandy do this on the /themes/blackcandy/templates/Page.ss

    <% if 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" >


Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.