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.

General Questions /

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

Baffled by empty <head> section


Reply


6 Posts   2254 Views

Avatar
ambient

Community Member, 123 Posts

25 June 2011 at 7:11am

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" xml:lang="en" >
<head>
<% base_tag %>
$MetaTags

<% require themedCSS(screen) %>

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

Avatar
Willr

Forum Moderator, 5513 Posts

25 June 2011 at 2:13pm

Edited: 25/06/2011 2:14pm

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.

Avatar
ambient

Community Member, 123 Posts

25 June 2011 at 11:25pm

Edited: 25/06/2011 11:47pm

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.

Avatar
mrProper

Community Member, 7 Posts

7 November 2011 at 5:18am

Edited: 07/11/2011 5:20am

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
Avatar
mrProper

Community Member, 7 Posts

7 November 2011 at 9:41pm

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.

Avatar
Terry-C

Community Member, 2 Posts

9 November 2011 at 8:07am

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