So you're wanting to pass a fully rendered element to the layout as a
variable?  Much in the same way we pass a fully rendered view to the
layout as $content_for_layout.

When building dynamic sidebars I created an array in the controller,
including the data and element name for each position in the sideber,
which I loop through in the view calling $this->element($element,
$dataArray());

You could do the same or if you must have things in the layout then
you would need to pass the array from the view to the layout and look
through it there calling the elements.

Either way the data is already available at the view and/or layout as
it is from there you call $this->element() and pass it the data.

HTH, Paul.

On Sep 6, 11:26 am, Xoubaman <[email protected]> wrote:
> My concrete case:
>
> In a CMS-like app, I have modules that can be attached to layout positions.
> Layout positions are vars echoed in each layout. So, I use a loader element,
> placed at the top of each layout, that should load each position var with
> his own output.
>
> Layout example:
>
> <head>
> <?php echo $this->elements('loader'); ?>
> </head>
> <body>
> ...
> <?php echo $position1; ?>
> ...
> <?php echo $position2; ?>
> ...
> </body>
>
> Loader behavior:
>
> foreach ($modules as $position => $attached_modules) {
> foreach ($attached_modules as $model) {
>  $output[$positions] .= $this->element($model);
>
> }
>
> $this->set($output);
>
> }
>
> Something like that. Code is not that way exactly, but I think it's enough
> to get the idea. The problem is that the $this->set at the bottom of loader
> element sets the var in viewVars attribute, but doesn't populate the vars to
> be accessed straight in the layout (as said in the doc, 
> here:http://book.cakephp.org/view/1086/set)
>
> I know I could call each element in each position, but it will mess up the
> layout code and difficult creating or editing layouts, instead the elegant
> echo $position ^^

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to