Zend Framework: Is there a View Helper to display View Name in Layout Class?

627 views Asked by At

As the title suggests, I'm trying to find a way of displaying the title of the View currently being displayed as part of the layout. I'm trying to do this so that the page title is dynamicly populated when a different view is selected.

In psuedocode:

<div>
   <div id="header"><h1>My website</h1></div>
   <div id="main">
           <?php echo "<h2>" . SOME WAY OF ECHOING THE VIEW NAME HERE . "</h2>"; ?>
           <?php echo $this->layout()->content; ?>
   </div>
   <div id="footer"><p>2011 My website.com></p>
</div>

I've been through the Zend documentation and the closest thing I could find was the headlink. However, I was unable to get the value from this helper and shoehorn it into a variable so that I could display its text as a page header for the view.

Thanks.

2

There are 2 answers

1
Patrick On BEST ANSWER

You could pass the action name (or combine with the module if needed) to the layout within the controller.

$layout = $this->_helper->layout->getLayoutInstance(); $layout->viewName = $this->_getParam("action");

Kind of dirty, but it would work

1
and_the_rand On

I´m not quite sure if I understood you right, but there´s something called a placeholder in ZendFramework. Basically you define the placeholder and fill it afterwards with whatever you want.