View this snippethttp://cakeforge.org/snippet/detail.php?type=packagever&id=44
There is custom view class cjsView.php.
On Sep 13, 7:23 pm, DanielSun <[EMAIL PROTECTED]> wrote:
> I am extreemly sorry for this mess. I must say I posted all the
> messages ONCE. even google isn't what it used to be :)
>
> I know that hacking core is not the thing to do. That is why i am
> trying hard to think of the way arround.
> Thanks Cris. But only passing variables TO the view doesn't help much
> here...
>
> I think I have thought out something interesting. Here it goes:
>
> - Copy paste entire controller::render() method into app_controller,
> renamed it (e.g. MYrender())
> - renamed the instance of viewClass object and renamed the last
> call to the view::render() method (now renderNOT)
> - copy paste entire view::render() function into myCustomView.php and
> renamed it (to e.g. renderNOT)
> - called myCustomView on the beginning of app_controller var
> $view=myCustom;
> - put $this->MYrender($this->action); into afterFilter in
> app_controller
>
> NOW I get all I wanted. I haven't messed with cake core code AND all
> the code (except for app_controller) is now "no-hack" competible.
>
> And the sweetness of the controller controlled layout objects?
>
> any_controller {
>
> function home(){
>
> $this->leftBlock= render('leftBlockView');
> $this->rightBlock=render('rightBlockView');
>
> $this->MainMenu=renderElement('MainMenu');
>
> $this->PageTitle=$this->action;
>
> }
> }
>
> default.thtml (layout)
>
> ***
> <div id="mainmenu"> <?=$this->controller->'MainMenu';?></div>
> <div id="leftBlock">
> <?=$this->controller->leftBlock;?>
> <div>
> <div id="rightBlock">
> <?=$this->controller->rightBlock;?>
>
> <div>
> **********
>
> Isn't that beautifull??
>
> I only hope everything else will work. Have to do some testing, will
> comeback.
>
> d
>
> [I hope this is not gonna post 100times again]
>
> On 13 sep., 15:30, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
>
> > On 9/13/07, DanielSun <[EMAIL PROTECTED]> wrote:
>
> > > Meaning I cannot at all make my own view class and I should instead
> > > use the allready instantiated view object __viewClass? Or should I
> > > make a new instance of view just for the purpose of rendering layout.
>
> > You can create your own view class if required. Nate is talking about
> > how to use your custom class. Here's a code snippet that might help:
>
> > * in the controller*
>
> > function foo() {
> > $this->view = 'bar';
> > $this->set('baz', $this->Baz->findAll());
>
> > }
>
> > This will tell Cake that for this action in the controller, you want
> > to use your 'bar' class for the view, which you should put in a file
> > named 'bar.php' that you place in your views directory. Then you can
> > pass stuff to it just like it was any other view and Cake will then
> > execute your custom view for you. We have used custom views to spit
> > out images for an internal project at CDC so that you can do things
> > like <img src=/controller/view/imageId> and have it display the image
> > you want.
>
> > > And therefore I cannot bypass hacking of the core?
>
> > Hacking the core is *always* a last resort because 99% of the time it
> > is done by people who do not understand how CakePHP works internally,
> > and 1% of the time it's to handle a legitmate problem with the code.
> > Spend some time learning how to create a custom view (I'm not aware of
> > any links off the top of my head) and I'm pretty sure that will handle
> > everything you need.
>
> > Hope that helps.
>
> > --
> > Chris Hartjes
> > Senior Developer
> > Cake Development Corporation
>
> > My motto for 2007: "Just build it, damnit!"
>
> > @TheBallpark -http://www.littlehart.net/attheballpark
> > @TheKeyboard -http://www.littlehart.net/atthekeyboard
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---