More dynamic page with sitecake?

2019-09-02 01:13发布

I've just started working with SiteCake which I really love! However it's not very dynamic to use as it - as far as I have read - isn't possible to have a main index.php file which holds header and footer and then includes the main content as it is needed.

I've been trying a few things now where I have individual files instead of index.php. This way I include the header and footer to the file, but this doesn't seem to work either.

I'm not sure how SiteCake renders the content on the page. I've tried the following:

<?php
include "sitecake/server/sitecake_entry.php";
ob_start();
/*file_get_contents("content/header.php");
file_get_contents("content/footer.php");*/
include "content/header.php";?>
<div class="sc-content-top"><h1>Velkommen til designature</h1></div>
<div class="clearfix"></div>
<div id="content">
<div class="content480 sc-content-left">
    <h2>Hvad kan vi?</h2>
</div>
<div class="content240 sc-content-middle">
    <h2>Hvad kan vi?</h2>
</div>
<div class="content240 sc-content-right">
    <h2>Hvad kan vi?</h2>
</div>
</div>
<?php 
include "content/footer.php";
ob_flush();
?>

The above code gives me this error:

An error occurred

Application error

Exception information:

Message: Undefined offset: 0

Stack trace:

#0 /home/smith/designature.dk/beta/sitecake/server/application/services/impl/basic/PageTemplateImpl.php(141): Bootstrap::globalErrorHandler(8, 'Undefined offse...', '/home/smith/des...', 141, Array)
#1 /home/smith/designature.dk/beta/sitecake/server/application/services/impl/basic/PageTemplateImpl.php(117): PageTemplateImpl->createTemplate()
#2 /home/smith/designature.dk/beta/sitecake/server/application/services/impl/basic/PageTemplateImpl.php(34): PageTemplateImpl->initTemplateEngine()
#3 /home/smith/designature.dk/beta/sitecake/server/application/services/impl/basic/RenderServiceImpl.php(54): PageTemplateImpl->setPageRequest('/beta/index.php')
#4 /home/smith/designature.dk/beta/sitecake/server/application/services/impl/basic/RenderServiceImpl.php(23): RenderServiceImpl->renderResponse()
#5 /home/smith/designature.dk/beta/sitecake/server/application/controllers/RenderController.php(13): RenderServiceImpl->render('/beta/index.php', false)
#6 /home/smith/designature.dk/beta/sitecake/server/library/Zend/Controller/Action.php(513): RenderController->renderAction()
#7 /home/smith/designature.dk/beta/sitecake/server/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('renderAction')
#8 /home/smith/designature.dk/beta/sitecake/server/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#9 /home/smith/designature.dk/beta/sitecake/server/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#10 /home/smith/designature.dk/beta/sitecake/server/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#11 /home/smith/designature.dk/beta/sitecake/server/sitecake_entry.php(45): Zend_Application->run()
#12 /home/smith/designature.dk/beta/index.php(2): include('/home/smith/des...')
#13 {main}  
Request Parameters:

array (
  'controller' => 'render',
  'action' => 'render',
)

I have no idea what the error means or how to fix it.

As I wrote I've also tried to do it the other way around where the index.php file is staionary and the content is then included. This allowed me to edit the page and it looked like it worked, however when I clicked "publish" it didn't save the content properly.

Do someone have any suggestions as to how I can get this to work?

Thanks

2条回答
戒情不戒烟
2楼-- · 2019-09-02 01:57

An answer just came op on the SiteCake page after requesting it - didn't think an official solution was available just yet. Here it is for everyone else: http://support.sitecake.com/entries/20258721-more-dynamic

查看更多
欢心
3楼-- · 2019-09-02 01:59

In SiteCake's documentation is solution, how use php code in templates: http://sitecake.com/using-php-in-templates.php

查看更多
登录 后发表回答