I have done quite a search before going into core code and besides
many people having questions there is not many solutions. There is one
soloution called "mini controllers" [http://www.noswad.me.uk/MiBlog/
MiniControllers] using components system (i have not examined it
indeep yet), but it seems too complicated for such a simple demand: to
have more layout elements.

I shall continue testing this hack. It doesn't seem to fail any of the
other view functions (e.g. caching, scaffolding), and on the end: it
is not that fundamental change afterall. Instead of view class calling
the final renderLayout method, this is done from within controller -
that's it.



On 11 sep., 18:57, MrTufty <[EMAIL PROTECTED]> wrote:
> On first glance, it sounds like you're trying to accomplish something
> similar to Django's templating system. Now, I like that system - with
> blocks that may or may not be replaced, being able to extend blocks,
> and putting content in multiple places. I've tried to implement
> something similar myself, but I gave up - I'm just not that good at
> the minute!
>
> I would definitely like to see something like this in Cake, but I
> doubt it'll go in core at this stage...
>
> On Sep 11, 3:11 pm, DanielSun <[EMAIL PROTECTED]> wrote:
>
> > 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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to