Reputation: 1282
I implemented a Zend project
And its working fine
Now i tried to implement a layout,
for that i created a 'layout.phtml' in the folder 'application/layouts'
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php echo $this->headTitle(); ?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php $this->layout()->content ;?>
</body>
</html>
Modified the application.ini and added the following line
resources.layout.layoutpath = APPLICATION_PATH "/layouts" under [production]
Modified the Bootstrap.php, and added the function '_initViewHelpers()'
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap{
function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_AutoLoader(
array('namespace'=>'','basePath'=>APPLICATION_PATH)
);
return $moduleLoader;
}
function _initViewHelpers()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$view->headTitle()->setSeparator(' - ');
$view->headTitle('Zend Framework Tutorial');
}
}
?>
I took the url in the browser http://localhost/zf_tutorial/public/
It showing the content of layout page but $this->layout()->content is not working (ie index action of index controller)
What is wrong with this code
Upvotes: 0
Views: 1003
Reputation: 22704
You need to echo your content. Either you can use
<?= $this->layout()->content ?>
OR
<?php echo $this->layout()->content ?>
Upvotes: 0
Reputation: 5693
You need to echo your content.
<?= $this->layout()->content ?>
will do what you want!
Upvotes: 1