Thanks Fahad and euromark. App::import() is a good method.
Althougt we should not use helper in controller or model, but sometimes they
also become useful.
For example, in my project, I need created a component called RssComponent.
And in this component, I have to make a new link which is based on
$html->url(). So, importing ('Helper','Html') is indeed.
Thank you very much.2009/9/8 djogo <[email protected]> > > Sometimes people (think they) need formatted data to come out from a > model, like date or time. > > However, if you follow MVC, that must be done at view level. That's > where all localization and internacionalization should be done. > > Same applies to a controller needing to access other controller. You > should redirect instead of importing and calling the class. > > dfcp > > > On Sep 7, 10:11 pm, "euromark (munich)" <[email protected]> > wrote: > > @fahad > > you should point out that you would need to create the object prior to > > using it > > for all those who are not so familiar with that > > > > App::import('Helper', 'Html'); > > $this->Common = new CommonHelper(); > > $foo = $this->Common->do(); > > > > sometimes this is not neccessary > > if the helper function does something on its own (without refering to > > other class vars or functions) > > you can access them statically > > > > $foo = CommonHelper::foo(); > > > > On 7 Sep., 21:35, Fahad <[email protected]> wrote: > > > > > I wouldn't suggest you use a helper in your controller. but you can do > > > it by importing your desired library. > > > > > in your controller: > > > App::import('Helper', 'Html'); > > > > > On Sep 7, 5:14 pm, cogitovn <[email protected]> wrote: > > > > > > Hi all, > > > > I'm a newbie in cakePHP. > > > > As I know, helper is a part of View. So, how to use a helper in > Controller > > > > or Model? > > > > For example, I want to Html helper, Xml Helper in a controller, in > order to > > > > call some methods such as, html->url(), xml->serialize().... > > > > Please help me on detail. > > > > Thank you! > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
