user2294256
user2294256

Reputation: 1049

layout.phtml issue in zend framework1

<?php
$this->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$this->headTitle()->setSeparator(' - ');
$this->headTitle('Zend Framework Tutorial');
echo $this->doctype(); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php echo $this->headMeta(); ?>
<?php echo $this->headTitle(); ?>
</head>
<body>
<div id="content">
<h1><?php echo $this->escape($this->title); ?></h1>
<?php echo $this->layout()->content; ?>
</div>
</body>

Above code is taken from this tutorial: http://akrabat.com/wp-content/uploads/Getting-Started-with-Zend-Framework.pdf it is on page 10, file is : zf-tutorial/application/layouts/scripts/layout.phtml

Question:

  1. what is this line for? $this->headTitle()->setSeparator(' - ');

  2. why we need this line: <?php echo $this->escape($this->title); ?> I guess 'escape' is for security, but what does it actully mean here?

Upvotes: 0

Views: 115

Answers (1)

Nandakumar V
Nandakumar V

Reputation: 4635

$this->escape()

By default, the escape() method uses the PHP htmlspecialchars() function for escaping. Escaping Output

$this->headTitle()->setSeparator(' - ');

When you add multiple values to a headtitle setSeparator will seperate the title with the specified seperator.Head Title

<?php
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->headTitle($request->getActionName())
     ->headTitle($request->getControllerName());
$this->headTitle('Zend Framework');   
$this->headTitle()->setSeparator(' - ');
?>   

<?php echo $this->headTitle() ?> will create <title>action - controller - Zend Framework</title>

Upvotes: 1

Related Questions