Hi. I'll go straight to code and contemplate later.

MY_CONTROLLER
{
var $layout_element1=null;
var $layout_element2=null;


function foo(){
      $this->layout_element1=$this->render('element1view');
      echo $this->__viewClass->renderLayout('nothing');

}

layout default.thtml
{
<div id="left_collumn">
     echo $this->controller->layout_element1;
</div>
<div id="right_column">
     echo $this->controller->layout_element2;
</div>

}


For this to work I had to HACK CORE CakePHP View class:
- line 300: comment out  $out = $this->renderLayout($out); which calls
renderLayout (to be able to call it from my_controller)
- line 306: comment out print $out;
- line 312: return $out; instead return true;  to be able to pass the
output to a variable inside controller instead of printing it out by
default.

Notes:
- set() method now passes variables to View NOT to layout. Layout
directly calls the controller variables.
- elements can still be called from within layout, view or even
controller.
- one can develop as many elements on the same page and pass any view
into them. views DONT render Layouts anymore, Controller does.
- renderLayout() only renders layout. Anything that you pass will be
passed to $content_for_layout in Layout.



I believe that due to my poor understanding such a hack might terribly
interfere with cake's view rendering. I would be checking especially
the downside of calling the view instance (__viewClass) from within
controller, which has been initiated in first render() call.


The REASON for this hack is, that I still haven't found any viable way
to implement "multi-$content_for_layout" template-driven app
architecture, which seems to me as not optimal in cakePHP.

A part of controller logic which is supposed to handle multiple page
elements (left column contents, etc) is in original Cake pushed either
into Views (since there is only one $content_for_layout) or to Layout
with use of elements. Both is not optimal from the point of view of
layout design separation and in complex page layouts produces a mess
in views/elements folders.
I rather see that all the controller actions are done inside a
controller class, views are rendered and then referred back to
controller where they are passed to respective variables later called
from Layout.
A solution with use of requestAction() has been proposed before, but I
wouldn't see why the same controller would have to be called twice
only to render two different html elements on the same page.



I would strongly appreciate your comments on this hack.


--~--~---------~--~----~------------~-------~--~----~
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