tags:

views:

363

answers:

2

Basically, I want to render a view and layout from a model. Don't ask me why.

First of all, the views work as intended and I'm loading them into a variable for my perverse use later on. I am also fully aware that I could always do partial scripts. It seems to be a valid fallback, but it just doesn't cut it.

What I want to do is to get the layout to work automatically just like in the case with controllers and views.

Right now I employ something like this:

// Class blablabla
$layout = new Zend_Layout();
$layout->enableLayout();
$layout->setView($view);

// Ugly url, I know, I'm experimenting and they work
$body = $layout->render('mailer/layout/mail');
$body .= $view->render('mailer/templates/' . $type . '.phtml');

The problem is that $body contains the layout and only then the actual view. Any advice? What am I doing wrong?

A: 

I think my first note would have to be that you're trying to use a hammer as a screwdriver. As I'm sure you know, in the MVC model the view is the rendering, and is logically distinct (separate) from the model. I'm not sure you're going to find a happy solution to this, since you're crossing the streams.

Zenham
I am well aware how MVC works. This function serves to generate a phtml (human readable/easy editable) stream to use as an email body, stored in the db to be sent out by a simple process that controls the email flow. Yes, anyone can use helpers, but 500 $html .= 'blablabla'; rows is a horrible approach. I can already, as I said, successfully use views to fulfill my dark needs. What I would appreciate is the layout working in a satisfactory way. See this as a latent MVC to parallel the standard one.
John
What I'm trying to say is that while the cross screwdriver is superior, I need a straight one now.
John
Gotcha, and thanks for being cordial when I was verifying the obvious. Good luck with this, I'm definitely not a ZF guru, and this question begs for one.
Zenham
+1  A: 

http://www.wowww.ch/index.php?post/2009/03/16/Zend-Mail-avec-template-standardise-avec-Zend-Layout-et-Zend-View

umpirsky
Ah voila, merci. Nous avons deja quelque chose pareil, mais ça peut encore être trés utile.
John
Is there an English translation?
Sonny
Use google translate ;)
umpirsky