Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Framework: headTitle()->append() issue

Has anyone run into this problem...

In my layout.phtml I have:

<head>
    <?= $this->headTitle('Control Application - ') ?>
</head>

then in index.phtml I have:

<? $this->headTitle()->append('Client List'); ?>

I expect that, when I go to my index action, the title should be 'Control Application - Client List' but instead I have 'Client ListControl Application - '

What is going on? How can I fix this?

like image 388
Andrew Avatar asked Feb 06 '09 18:02

Andrew


2 Answers

Default behaviour of the headTitle() is to append to the stack. Before calling headTitle() in layout.phtml, your stack is:

Clientlist

Then, you call headTitle with the first argument and no second argument (which makes it default to APPEND), resulting in the following stack:

ClientListControl Application -

The solution, in layout.phtml:

<?php 
    $this->headTitle()->prepend('Control Application -');
    echo $this->headTitle();
?>
like image 61
Aron Rotteveel Avatar answered Sep 22 '22 20:09

Aron Rotteveel


Additionally, you can use the setPrefix method in your layout as such:

<head>
    <?= $this->headTitle()->setPrefix('Control Application') ?>
</head>

And in your controllers/actions/etc use the standard append/prepend:

<?php
$this->headTitle()->setSeparator(' - ');
$this->headTitle()->append('Client List');
?>
like image 40
gmcrist Avatar answered Sep 23 '22 20:09

gmcrist