On Dec 27, 2007 3:07 PM, subtropolis zijn <[EMAIL PROTECTED]> wrote:
>
> My controller:
>
> function index()
> {
> $this->autoRender=false;
> $this->set('publish_date', date('Y-M'));
> $this->render('view');
> }
>
> function view()
> {
> $this->pageTitle = 'The Archive: ' . $this->publish_date;
> $this->set('newsletter',
> $this->Newsletter->findByPublishDate("{$this->publish_date}-01"));
> }
>
> This is failing miserably because, no matter how I approach it, the
> $publish_date var is not set. So it seems that I have a fundamental
> misunderstanding about setting class vars in Cake.
>
Given that there are lots examples of how to pass data from controller
to views, it leads me to wonder if you have actually read the manual
for CakePHP or followed along with some examples because if you saw
those examples you would immediately understand why what you are
trying to do will not work. If you have read them, my apologies
because we must've read two totally different sets of documentation.
Also feel free to check out http://tempdocs.cakephp.org for some Cake
1.2 documentation.
As nice as it would be, telling the index() action to use a view
called 'view' does not mean that the action called 'view' is magically
run as well. If you want $publish_date to show up in a view (wherever
that view might be) you need to make sure you do a
$this->set('publish_date', date('Y-m-d')) in the same action where you
are doing $this->view('view');
Why? Because that's the way CakePHP needs you to do it. To do
anything else is banging your head against the framework in a most
uncomfortable way.
--
Chris Hartjes
My motto for 2007: "Just build it, damnit!"
@TheKeyboard - http://www.littlehart.net/atthekeyboard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---