Personally, I like the ability to pass variables to elements, it
allows me to reuse them on the same view.

For instance I have a page that displays two tables of the same type
of data: one is volunteer time slots that people can still sign up
for, and the other is to show the time slots that the logged in user
has signed up for.

In the view, I just call the same element twice, passing the data that
is to be displayed in each case.

I reuse the same element to display different slices of the same data
on other pages, and you could even do a drill down that way.

Personally I like keeping the element abstract and treating it like a
separate object and relying on the passed data as much as possible.

On Feb 7, 4:02 am, WebbedIT <p...@webbedit.co.uk> wrote:
> Should you be using $this->set in a view?  Set is used in the
> controller to pass a variable to the view then you pass on those
> variables to the element within the element call ...
>
> $this->element('view', array('var1' => $var1, 'var2' => $var2));
>
> My previous query still remains unanswered though as any variables you
> place in the $this->data array are automatically available in all
> views and elements, but is it ok/proper to pass variables in this way?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to