0

I am trying to install sitecake, I followed all the instructions by adding <?php include "sitecake/server/sitecake_entry.php"; ?> on the top of the page and classes to the divs that I want to be edited.

The problem is, when I add <?php include "sitecake/server/sitecake_entry.php"; ?> my PHP stops working, why is that? what I am doing wrong?

For example, here is one of my PHP scripts that is added to the pages using PHP include:

<!--add class .active to current page-->
<?php
   $directoryURL = $_SERVER['REQUEST_URI'];
   $path = parse_url($directoryURL, PHP_URL_PATH);
   $components = explode('/', $path);
   $currentPage = preg_replace("/\\.[^.\\s]{3,4}$/", "", end($components));

   if ($currentPage == "") {
      $currentPage = "index";
   }

   function href($url) {
      global $currentPage;
      $path = explode('/', $url);
      $page = preg_replace("/\\.[^.\\s]{3,4}$/", "", end($path));
      echo 'href="' . $url . '" ';

      if ($page == $currentPage) {
         echo 'class="active"';
      }
   }
?>

Here is the error I get when I use error_reporting(E_ALL):

Fatal error: Uncaught exception 'Zend_Session_Exception'
  with message 'Session must be started before any output has been sent to the browser; output started in /home/approach/public_html/index.php/2'
  in /home/approach/public_html/sitecake/server/library/Zend/Session.php:454

Stack trace:
#0 /home/approach/public_html/sitecake/server/library/Zend/Session/Namespace.php(143): Zend_Session::start(true)
#1 /home/approach/public_html/sitecake/server/application/services/impl/onesite/Bootstrap.php(21): Zend_Session_Namespace->__construct('Default', false)
#2 /home/approach/public_html/sitecake/server/library/Zend/Application/Bootstrap/BootstrapAbstract.php(666): Bootstrap->_initSession()
#3 /home/approach/public_html/sitecake/server/library/Zend/Application/Bootstrap/BootstrapAbstract.php(619): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('session')
#4 /home/approach/public_html/sitecake/server/library/Zend/Application/Bootstrap/BootstrapAbstract.php(583): Zend_Application_Bootstrap_BootstrapAbstract->_bootstra in /home/approach/public_html/sitecake/server/library/Zend/Session.php on line 454
Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146

1 Answers1

0

Your error message is this:

Session must be started before any output has been sent to the browser; output started in /home/approach/public_html/index.php/2

And the error occurred at:
/home/approach/public_html/sitecake/server/library/Zend/Session.php:454

The full explanation of the meaning of this message is already explained in detail at another answer, I highly recommend that you read this answer to get a better example of what's going on.

For your specific case, it would seem that you're including your sitecake_entry.php script at the top of the page, or, at least somewhere before you initialize Zend. What you want to do, is this (from the SiteCake examples page):

<?php include "sitecake/server/sitecake_entry.php"; ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

I don't know the details of Zend, or your application in particular, the thing you probably want to do is find your HTML template, you could search your projects's directory for <!DOCTYPE, and add the line above that, as per the example, instead of adding it to your index.php.

Community
  • 1
  • 1
Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146