The problem is doing $this->$Html-> It should be $this->Html->
On Sunday, March 29, 2015 at 9:49:57 PM UTC+2, Odedere Ayokunle wrote: > > Greetings everyone here. I am combining one Andrew Perkin video tutorial > (which explains cakephp in a step by step manner but quite stale) with the > official cake forum example (more current but less explanatory) in learning > cakePHP. The first thing I learnt how to do was to view all posts on the > index page, which works very fine. Then I proceeded to using "id's" to view > individual posts through the "view" action, this also works perfectly. My > challenge started when I wanted to link titles on the index page to their > individual forum posts. I do not seem to get the link class well. I tried > Andrew Perkin's approach but I was showed errors. Then I updated his > version to the official cake example style (adding helpers, exception for > null id's, etc), but still I am being told that "Fatal Error > > *Error: *Cannot access empty property > *File: *C:\xampp\htdocs\cakephp\lib\Cake\View\View.php > *Line: *867" > > The surprising thing about this error is that I have never edited the > contents on the ../lib directory. So I do not know how to rectify it. I am > only used to the ../app directory. > > Kindly find my code below and the associated file paths: > > MODEL > cakephp/app/Model/Writeup.php > > <?php > class Writeup extends AppModel { > var $name='Writeup'; > } > ?> > > CONTROLLER > cakephp/app/Controller/WriteupsController.php > > class WriteupsController extends AppController { > public $helpers = array('Html','Form'); > > public function index() { > $this->set('writeups',$this->Writeup->find('all')); > } > > public function view($id = null) { > $this->set('writeup',$this->Writeup->findById($id)); > } > > public function hello_world() { > } > } > ?> > > VIEW > cakephp/app/Views/Writeups/index.ctp > <h2> View All Posts</h2> > > <table> > <tr> > <th>Title</th> > <th>Body</th> > </tr> > <?php foreach ($writeups as $writeup): ?> > <tr> > <td><?php echo $this->$Html->link($writeup['Writeup']['title'], > array('controller'=>'writeups', > 'action'=>'view',$writeup['Writeup']['id']));?> </td> > <td><?php echo $writeup['Writeup']['body'];?> </td> > > </tr> > <?php endforeach; ?> > </table> > > ###################################################################### > cakephp/app/Views/Writeups/view.ctp > > <h2> <?php echo $writeup['Writeup']['title'];?></h2> > <p><?php echo $writeup['Writeup']['body'];?></p> > > <p><small>Created on: <?php echo $writeup['Writeup']['created']; ?> > Last modified on: <?php echo $writeup['Writeup']['modified']; > ?></small></p> > ####################################### > Once again, the error being provided by the debugger is that "Cannot > access empty property" and the file path of the error is " > C:\xampp\htdocs\cakephp\lib\Cake\View\View.php", a path that I have never > edited. > > Thank you. > > > > > > > > > > > > > > > > > > > > > > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/d/optout.