On Wed, October 6, 2010 2:20 pm, Tilen Majerle wrote:
> u can load data from models with helpers....
>
> use ClassRegistry::init("ModelName", "Model"); or App::import();
>
> read cakephp manual about this...Although you *can* do this, its breaking cake MVC conventions. Really you should be loading data from model into controller and then passing into the view for the helper to process. > > -- > Tilen Majerle > http://majerle.eu > > > > 2010/10/6 Mike Karthauser <[email protected]> > >> hi hoss >> >> helpers are for manipulating views and shouldn't/ can't be used to load >> data from models. >> >> perhaps you are better suited with a component? >> >> mikek >> >> >> On Wed, October 6, 2010 1:09 pm, hoss7 wrote: >> > i have this: >> > class SubcatHelper extends Helper { >> > >> > >> > >> > function find($id){ >> > >> > $subcat = >> $this->Subcat->Cat->find('all',array('conditions' >> => >> > array('Subcat.status' => 1,'Subcat.id'=>2))); >> > >> > return $subcat; >> > >> > } >> > >> > >> > } >> > >> > in SubcatsController this code >> > >> > $usercats = $this->Subcat->Cat->find('all',array( >> > 'conditions' => array( >> > 'Cat.status' => 1 >> > ))); >> > >> > work but in subcathelper i have this error >> > >> > Notice (8): Undefined property: SubcatHelper::$Subcat [APP\views >> > \helpers\subcat.php, line 8] >> > Code | Context >> > >> > function find($id){ >> > >> > >> > >> > $subcat = $this->Subcat->Cat->find('all',array('conditions' => >> > array('Cat.status' => 1))); >> > >> > $id = 2 >> > >> > SubcatHelper::find() - APP\views\helpers\subcat.php, line 8 >> > include - APP\plugins\spark_plug\views\users\index.ctp, line 29 >> > View::_render() - CORE\cake\libs\view\view.php, line 723 >> > View::render() - CORE\cake\libs\view\view.php, line 419 >> > Controller::render() - CORE\cake\libs\controller\controller.php, line >> > 913 >> > Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 207 >> > Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171 >> > [main] - APP\webroot\index.php, line 83 >> > >> > Notice (8): Trying to get property of non-object [APP\views\helpers >> > \subcat.php, line 8] >> > Code | Context >> > >> > function find($id){ >> > >> > >> > >> > $subcat = $this->Subcat->Cat->find('all',array('conditions' => >> > array('Cat.status' => 1))); >> > >> > $id = 2 >> > >> > SubcatHelper::find() - APP\views\helpers\subcat.php, line 8 >> > include - APP\plugins\spark_plug\views\users\index.ctp, line 29 >> > View::_render() - CORE\cake\libs\view\view.php, line 723 >> > View::render() - CORE\cake\libs\view\view.php, line 419 >> > Controller::render() - CORE\cake\libs\controller\controller.php, line >> > 913 >> > Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 207 >> > Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171 >> > [main] - APP\webroot\index.php, line 83 >> > >> > >> > Fatal error: Call to a member function find() on a non-object in D: >> > \xampp\htdocs\ird\www\app\views\helpers\subcat.php on line 8 >> > >> > >> > how can i use some function in helper like function in Controller? >> > >> > 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 >> > >> > >> >> >> -- >> Mike Karthauser >> Managing Director - Brightstorm Ltd >> >> Email: [email protected] >> Web: http://www.brightstorm.co.uk >> Tel: 07939 252144 (mobile) >> Fax: 0870 1320560 >> >> Address: 1 Brewery Court, North Street, Bristol, BS3 1JS >> >> 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 > -- Mike Karthauser Managing Director - Brightstorm Ltd Email: [email protected] Web: http://www.brightstorm.co.uk Tel: 07939 252144 (mobile) Fax: 0870 1320560 Address: 1 Brewery Court, North Street, Bristol, BS3 1JS 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
