|
|||
|
Hi!
I'm upgradating to version 1.0.0 and I have a problem. In IndexController I had this function: Code:
function indexAction()
{
$this->view = Zend_Registry::get('view');
$this->view->title = "School";
$this->view->actionTemplate = 'index.phtml';
$this->_response->setBody($this->render('base.phtml'));
}
Code:
function indexAction()
{
this->view->title = "School";
$this->render();
}
Code:
<html>
<head>
<title><?php echo $this->escape($this->title); ?></title>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo $this->baseUrl;?>/public/styles/site.css" />
</head>
<body>
<div id="wrapper">
<div id="header">
<?php echo $this->render('header.php')?>
</div>
<div id="body">
<div id="menu">
<?php echo $this->render('menu.php')?>
</div>
<div id="content">
<?php echo $this->render($this->actionTemplate); ?>
</div>
</div>
<div id="footer">
Contact
</div>
</div>
</body>
</html>
But now, how do I do this? The way I was doing it it doesn't work now! And if I have to put the whole code in each Action is crazy!! Thank you and sorry for the lenght! Last edited by enkara : 06-12-2007 at 11:16 PM. |
|
|||
|
rc2 has a viewRenderer that includes views automatically - so no need to call $this->render()
And this is how I render my pages: PHP Code:
|
|
||||
|
You may not even need the $this->render() call if ViewRenderer is enabled - it's called automatically using a template of the form:
./views/scripts/{controllerName}/{actionName}.phtml If that "specification" isn't correct for your application you can change it quite easily. Have a read here and let me know if it doesn't cover your case: Having a bad ViewRenderer day in your ZF app? - Maugrim The Reaper's Blog |
|
|||
|
Ok! I've found a solution. I don't know if it's good or not, but at least it works.
In IndexAction: PHP Code:
PHP Code:
![]() |
|
||||
|
Kinda hacky... What is wrong with passing it to the view object and rendering it from there?
__________________
Zym Framework - A Zend Framework extension library w/ demo app SpotSec Blog: http://spotsec.com/blog |
|
|||
|
Ok... I don't know anything of ZF or php, I'm just starting. Yes, base is common to absolutely all views. What happens is that I don't usually speak English and I don't know how to explain things.
I will have a look to some tutorial to find out how to use that Zend_Controller_Action. I don't have one ![]() Tank you very much! |
|
|||
|
I have a dilemma. Do you both think that the way I'm assuring to pass first for my base archive could give me problems or it consumes too many resources?
Because I don't understand ZF API. I don't know why, I think I need more explanation and concrete examples. First of all, I don't like the idea of disabling the viewRendering. I don't know why. Maybe because I think it's like going backwards. Then I tried the second alternative that Maugrim offers me in his page, and changing it a bit I came to my solution. Then I thought that that way wasn't good enough, because of your comments. I looked at the ZF API how to make that with view helpers as spotSec said. But I think that putting in each action to render the head and the footer and then in each template call the helper was too repetition of code. Then I read Zend_Controller_action subclassing and I just don't understand how it works. Then I read the post of another guy that wanted to do the same as me but only with the head and the foot and I found Maugrim two-step pattern. I was going to try it, but I wanted first your opinion because for me this is very complicated. What do you think I should do? I know this is a difficult question and that I'm abusing of your amability, but I'm very lost! I just want to do a standard webpage that always shows the same things in ALL pages (head, menu, footer) and only change the content!! Thank youuuu |
|
||||
|
well, unofficially, padraic and ralphschindler both have their unofficial components at the moment that deal with layouts. I'm sure padraic and explain his
. As for ralphschindler's, you can try and ask a few people on zftalk about it. I am preparing an example zf application which *might* be using it in the next who noes (days/weeks)...
__________________
Zym Framework - A Zend Framework extension library w/ demo app SpotSec Blog: http://spotsec.com/blog |
![]() |
| Thread Tools | |
| Display Modes | |
|
|