needs to be a component. setting it up is very similar to a helper. please see the link robert supplied.
On Aug 4, 8:55 pm, Robert P <[email protected]> wrote: > Where you're going wrong: Helpers are related to and accessed from > within the View, not the Controller like you're trying to > do.http://book.cakephp.org/view/98/Helpers > > In /app/views/about/index.ctp replace > <?php echo $text; ?> > with > <?php echo $content->get('about_team'); ?> > and you can get rid of the contents of your AboutController::index() > function. > > Perhaps the functionality you're after is more suited to a > Component?http://book.cakephp.org/view/63/Introduction > > On Aug 5, 1:24 am, Kai <[email protected]> wrote: > > > Hi there, > > > I just wrote my first helper and, sure enough, ran into some problems. > > For some reason my helper is not being loaded. As I could not find > > anything similar I just expect something to be done wrong in my code. > > > My Helper (/app/views/helpers/content.php): > > <?php > > class ContentHelper extends AppHelper{ > > function get($id){ > > $t = $this->requestAction('texts/get/'.$id); > > return $this->output($t); > > }} > > > ?> > > > I placed it like this into $helpers in my app_controller (/app/ > > app_controller.php): > > var $helpers = array('Content'); > > > And finally in my Controller (/app/controllers/about_controller.php) I > > use it like this: > > function index(){ > > $this->set("text", $content->get('about_team')); > > } > > > However, no matter how I twist and turn it (putting it into the > > Controllers $helper, writing it differently) I always get the same > > error-message: > > Undefined variable: content [APP/controllers/about_controller.php, > > line 7] > > > During this process I learned that I do not get any error-messages > > about my Helper-File at all. I've put an PHP-Error (deleting the > > last }) into it without complaints. Heck, I can write whatever I want > > into $helper and do not get any errors. It seems like to me that my > > Helper is never loaded, $helper never parsed for any custom helpers. > > > Does anybody have a clue what I might be doing wrong? > > > My Cake-Version is 1.2.3.8166. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
