Monday, November 2, 2009

Re: Helper or Model Function?

Helpers are used in Views and if you pass data from the Controller to
the View, then the Helper has access to the data.
The View has no direct access to Model data.

That is why I suggested using requestAction in an Element to get the
needed data.

Enjoy,
John

On Nov 2, 7:50 pm, 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: