Hi,
what I did is exactly what euromark did; except that I wrapped it into a
method in app_controller:
function loadInexistentModel($Model){
if(!isset($this->$Model)){
$this->loadModel($Model);
}
}
I think it's the best option
Best,
Nicolás Andrade
www.nmac.com.ar
www.nicoandra.com.ar
On Tue, May 18, 2010 at 2:14 PM, euromark <[email protected]>wrote:
> sometimes it might already be available, sometimes not
>
> if (!isset($this->ModelName)) {
> $this->ModelName = ClassRegistry::init('ModelName');
> }
> $this->ModelName->getNav();
> ...
>
> On 18 Mai, 15:37, "Dr. Loboto" <[email protected]> wrote:
> > $this->loadModel('Section');
> > $this->Section->getNav();
> >
> > On May 18, 4:45 pm, "[email protected]" <[email protected]>
> > wrote:
> >
> >
> >
> > > In most projects I find I need to reference one model in every context
> > > say for example 'sections' which holds the top level navigation,
> > > usually I place a function in the app_controller that gets the
> > > navigation details and adds them to the view, whats the best way to
> > > access the model ?
> >
> > > Currently I'm using;
> > > $this->{$this->modelClass}->Section->getNav();
> >
> > > which is messy, or
> >
> > > $section = ClassRegistry::init('Section');
> > > $section->getNav();
> >
> > > a bit better, but what is the 'proper' way to do it?
> >
> > > chris
> >
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others
> with their CakePHP related questions.
> >
> > > You received this message because you are subscribed to the Google
> Groups "CakePHP" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<cake-php%[email protected]>For
> > > more options, visit this group athttp://
> groups.google.com/group/cake-php?hl=en
> >
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> with their CakePHP related questions.
> >
> > You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<cake-php%[email protected]>For
> > more options, visit this group athttp://
> groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<cake-php%[email protected]>For
> more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" 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