I did search... That's how I found this... ah, nevermind.

Anyway, I _know_ how to use helpers in controllers. I wasn't asking
how to do it. I was trying to get people's perspective on the issue
and, specifically, whether the Cake developers really intend on
helpers being used exclusively in views. I mean, why would a core
helper include a method to convert a date into an SQL expression if
it's supposed to be for views only?

I like the inheritance approach, but I'm not sure how that would work
(does PHP support multiple inheritance?). My original thought was that
you could just create a component first, and then the helper can just
be an interface for the component through composite reuse. But this
doesn't actually help me when I want to use Cake's core helpers in my
controllers. And if I'm trying to write functions that can be used in
both controllers and views, then I'd just write them in the bootstrap
or load them from a vendor file.

On Apr 21, 1:30 am, euromark <dereurom...@googlemail.com> wrote:
> and no
> its not that much of a taboo as long as there arent any corresponding
> components/libs etc
>
> the cleaner approach would be to write lib classes that get inherited
> from both a component for controllers
> and the helper for views
> but as long as it is not so you have to break with the design a little
> bit in order to avoid code redundance
>
> just import the helper as mentioned in the link
> for those time functions it is usually not neccessary to do that - a
> simple date(...) call usually does the trick
> but for flash messages with some formatting in it or other similar
> matters i had to use some helpers, too
>
> and it does only work for helpers that are independent (which dont
> call $this->AnyOtherHelper inside each other)
>
> On 21 Apr., 10:20, euromark <dereurom...@googlemail.com> wrote:
>
>
>
> > this question has been answered like a million times
> > please try to search for it first!
> > "helper controller" in the above search field gets
>
> >http://groups.google.com/group/cake-php/browse_thread/thread/64c8ae45...
> > + many others
>
> > On 21 Apr., 07:10, calvin <cal...@rottenrecords.com> wrote:
>
> > > So I just encountered a situation where I'd like to use a helper in my
> > > controller even though this seems to break with Cake's MVC design.
> > > Googling the topic turned up a thread in this group in which
> > > loadHelper() is proposed as a means of doing just that, but it still
> > > seems to be discouraged.
>
> > > What I'm wondering is, if this is discouraged, then why does the Time
> > > Helper have day/daysAsSql(). I cannot fathom a common scenario where
> > > you would need to display a date as:
>
> > > ($field_name >= '2008-01-21 00:00:00') AND ($field_name <= '2008-01-21
> > > 23:59:59')
>
> > > in a view to justify the inclusion of those two functions in a helper
> > > rather than a component.
>
> > > Is using a helper in a view really so taboo?
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
> > > 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 cake-php@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > > athttp://groups.google.com/group/cake-php?hl=en
>
> > 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 cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to