use
ClassRegistry::init('ModelName')->find(...);
API: http://api.cakephp.org/class/class-registry#method-ClassRegistryinit
But I agree with John, use requestAction if you need to pull in data
from a view. Here's a thought, is there a way to pass in the needed
flag record to your view? In your controller action, maybe something
like:
$this->set('showLink', $this->Model->find(/*conditions for specific
record*/));
Then in your view you could just:
<? if($showLink):?> LINK <? endif; ?>
-Nick
On Nov 2, 10:50 am, dtirer <dti...@gmail.com> wrote:
> Hi John, thanks for the info. I'll give that a whirl
>
> A general question: do helpers have access to Model data, or would
> you need to import the Model into the helper to access data like
> that?.
>
> Im just getting into Helpers, Components, etc so I'm trying to figure
> out when its best to use each
>
> On Nov 2, 12:25 pm, John Andersen <j.andersen...@gmail.com> wrote:
>
> > Based on the information you provided (not enough):
>
> > One possible solution is to have a separate Element to create the
> > link, when the database contains the specific record.
> > The element will use requestAction to query the database for the
> > specific record, and display/not display the link depending on the
> > reply.
>
> > Turn on cache for the element, so that the requestAction is only used
> > once in each session.
>
> > Enjoy,
> > John
>
> > On Nov 2, 5:40 pm, dtirer <dti...@gmail.com> wrote:
>
> > > So here's my scenario. On a particular page, I want to display a link.
> > > However, I only want to display this link if a particular record
> > > exists in the database.
>
> > > Firstly, do helpers have access to DB/Model info?
>
> > > If so, should I make a helper to check if the records exists in the
> > > DB?
>
> > > Whats the best way to do this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment