If I'm not wrong, your viewVars are always passed to the element. So
in fact once you've set the vars using $this->set() on your
controller, all the elements could receive those variables as well
even if you don't specifically provide the params when calling
renderElement.

That said, I may have misunderstood your question. :p

On Apr 22, 10:03 am, Gonza <[EMAIL PROTECTED]> wrote:
> Hi Mariano,
>
> Gracias. Like you said, it's not the most elegant solution but it'll
> probably work.
>
> Thanks!
> Gonzalo
>
> On Apr 21, 8:55 pm, "Mariano Iglesias" <[EMAIL PROTECTED]>
> wrote:
>
> > You can do it through a quick hack, though it is not very elegant. Let's say
> > that on your view you have:
>
> > <?php echo $this->renderElement('element1', array('arg1' => 'Hello', 'arg2'
> > => 'World')); ?>
>
> > And element1 includes element2. Element2 looks like:
>
> > <?php echo $arg1 . ' ' . $arg2; ?>
>
> > Then the hack is to make element1 look like:
>
> > <?php
>
> > $loaded = am(array_keys($this->viewVars), array_keys($this->loaded));
> > $args = array_diff_key($___dataForView, array_flip($loaded));
>
> > echo $this->renderElement('element2', $args);
>
> > ?>
>
> > -MI
>
> > ---------------------------------------------------------------------------
>
> > Remember, smart coders answer ten questions for every question they ask.
> > So be smart, be cool, and share your knowledge.
>
> > BAKE ON!
>
> > blog:http://www.MarianoIglesias.com.ar
>
> > ________________________________________
> > De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre
> > de Gonzalo Servat
> > Enviado el: Sábado, 21 de Abril de 2007 08:35 p.m.
> > Para: cake-php@googlegroups.com
> > Asunto: Re: Passing arguments to a nested element
>
> > .. but not quite the solution I was looking for. What I'm trying to avoid is
> > having to specifically write each and every variable in either method. I was
> > hoping for a way to grab them all and send the arguments to the next
> > renderElement call. Maybe I understood how to use compact? I'd really
> > appreciate an example.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to