Jump to:

23355 Posts in 17873 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Baffled by empty <head> section

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

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

Page: 1
Go to End
Author Topic: 2145 Views
  • ambient
    Avatar
    Community Member
    123 Posts

    Baffled by empty <head> section Link to this post

    Hi all, I have a very curious issue and I'm absolutely stumped as to why its happening

    When I check my site using firebug it shows the head section as empty and the code from it in the body section??? With 2 empty paragraphs that are not in my Page.ss

    When I try to validate on w3c it says "No DOCTYPE found, and unknown root element. Aborting validation" and "No XML declaration (e.g <?xml version="1.0"?>) " but they are both in my Page.ss.

    I'm very confused by this and hope someone can help. Thanks for listening

    This is what shows in Firebug

    <html lang="en">

    <head></head>

    <body>
    <p>&nbsp;</p>
    <p>&nbsp;</p>

    <base href="http://mysite.com/">
    <title>mysite | About</title>
    <meta content="SilverStripe - http://silverstripe.org" name="generator">
    <meta content="text/html; charset=utf-8" http-equiv="Content-type">

    <base href="http://mysite.com/preview/"><!--[if lte IE 6]></base><![endif]-->
    <!--<title>mysite | About</title>
    <meta name="generator" content="SilverStripe - http://silverstripe.org" >
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" >
    -->
    <meta content="noindex, nofollow" name="robots">

    <link href="-----------------------------------------------------------------------" type="text/css" rel="stylesheet">
    <link href="-----------------------------------------------------------------------" type="text/css" rel="stylesheet">

    <div id="container">

    And this is what my Page.ss looks like

    <?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

    <% require themedCSS(screen) %>

    </head>
    <body>
    <div id="container">

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: Baffled by empty <head> section Link to this post

    Is the final site using your Page.ss some other template? I would recommend against using the xml header now and using an HTML5 doctype.

  • ambient
    Avatar
    Community Member
    123 Posts

    Re: Baffled by empty <head> section Link to this post

    Oh dear, Hi Will,
    I just found two paragraph tags at the top of my Home.php page.
    I can't believe it. Don't know how I managed to put them there or why I couldn't find them yesterday when I did a sitewide search.

    Anyhoo, sorry for the fuss, rest assured my face is red.

    Thanks for the help.

  • mrProper
    Avatar
    Community Member
    7 Posts

    Re: Baffled by empty <head> section Link to this post

    Hi guys,
    I got the same problem as described above with the difference I haven't empty paragraphs in my Page.php
    Here is my Page.php

    <?php
    class Page extends SiteTree {

       public static $db = array(
       );

       public static $has_one = array(
       );
       
       function getAboutLink() {
          $menulink = parent::get_by_link('about')->Link();
          return $menulink;
       }
       
       function getBuyLink() {
          $menulink = parent::get_by_link('buy')->Link();
          return $menulink;
       }

    }
    class Page_Controller extends ContentController {

       public static $allowed_actions = array (
       );

       public function init() {
          parent::init();

          // Note: you should use SS template require tags inside your templates
          // instead of putting Requirements calls here. However these are
          // included so that our older themes still work
          Requirements::javascript('http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js');
          Requirements::javascript('mysite/javascript/cufon-yui.js');
          Requirements::javascript('mysite/javascript/Myriad_Pro_400.font.js');
          Requirements::javascript('mysite/javascript/m-a.js');
       }
       
    }

    Here is templates/Page.ss:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html lang="$ContentLocale">
       <head>
          <% base_tag %>
          <title><% if MetaTitle %>$MetaTitle<% else %>$Title<% end_if %> &raquo; $SiteConfig.Title</title>
          $MetaTags(false)
          <link rel="shortcut icon" href="/favicon.ico" />
          
          <% require themedCSS(bootstrap) %>
          <% require themedCSS(layout) %>
          
          <!--[if lt IE 9]>
             <style type="text/css">
              @import url(themes/macslaw/css/ie.css);
             </style>
          <![endif]-->
       </head>
       <body>
       
          <div class="wrapper">
          <!-- Begin Header -->
             <% include TopHeader %>
             <div class="clearfloats"><!-- --></div>
             <% include MainHeader %>
             <div class="clearfloats"><!-- --></div>
          <!-- End Header -->
          <!-- Begin announce-head -->
             <% include AnnounceHeadInner %>
             <div class="clearfloats"><!-- --></div>
          <!-- End announce-head -->
          <!-- Begin Content -->
             $Layout
          <!-- End Content -->
          <!-- Begin Footer -->
             <% include Footer %>
          <!-- End Footer -->
          </div>
          
       </body>
    </html>

    and templates/Layout/Page.ss:

    <div class="main-content" id="main-content">
       <div class="container">
          <div class="row">
             <!-- Begin top row -->
             <div class="span17 columns round-box gradientV soft-info" id="soft-info">
                <div class="soft-info-header">
                   <h3>$Title</h3>
                </div>
                <div class="soft-info-body">
                   $Content
                </div>
                
             </div>
             
             <!-- End top row -->
          </div>
       </div>
    </div>

    I attach the console from Chrome with the page structure where can see that the head tags are in the begining of the body.
    I'm very confused and I lost many hours in research of this "effect". The bigger problem is that in the begining of the <body> tag stays empty string " " which brokes the frontend.

    Can anybody help?

    Attached Files
  • mrProper
    Avatar
    Community Member
    7 Posts

    Re: Baffled by empty <head> section Link to this post

    I found where the problem is!
    It was in the encoding of the source files - SS source files are in ANSI, but my template files - UTF8. Made them equal solves the problem.

    Hope this helps somebody.

  • Terry-C
    Avatar
    Community Member
    2 Posts

    Re: Baffled by empty <head> section Link to this post

    SILVERSTRIPE DEVELOPERS - I HAVE A PAYING JOB FOR YOU!

    A coder used this CMS a few years ago to build a site that now has gone a bit funny, and it would be great to hear from any SilverStripe pros who can help us fix the site.

    This is paid work for a site where the CMS seems to have permissions issues connecting to the database... possibly because a 1and1.co.uk server update/upgrade or some other actions they took. We have a backup of when the site went live, so we can supply all the files that a pro could use to fix it.

    Please email Terry terry@division100.com and Christian Barnes christian@blackboxpartnership.com to get more details.

    If there is a better place for us to post this type of message to recruit developers, please do let us know...

    Many thanks
    Terry and Christian

    2145 Views
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.