CakePHP Blog Eğitimi ile yardım

0 Cevap php

Ben sadece Cake hakkında biraz bilgi edinmek için bir yol olarak basit bir blog oluşturmak için CakePHP web sitesinde öğretici takip ettik. Ancak ben bir hata içine çalıştırmak ve öğretici diyor tam olarak ne takip ettim neden emin değil. Hataları:

Notice (8): Undefined property: View::$Html [APP/views/posts/index.ctp, line 17]
Fatal error: Call to a member function link() on a non-object in /Users/cameron/Sites/dentist/app/views/posts/index.ctp on line 17

İşte benim posts_controller olduğunu

<?php
class PostsController extends AppController {
    var $helpers = array('Html', 'Form');
    var $name = 'Posts';

    function index() {
         $this->set('posts', $this->Post->find('all'));
    }

    function view($id = null) {
        $this->Post->id = $id;
        $this->set('post', $this->Post->read());
    }
}
?>

ve burada benim modeli

<?php

class Post extends AppModel {
    var $name = 'Post';
}

?>

ve burada benim görünümleri

<!-- File: /app/views/posts/index.ctp -->

<h1>Blog posts</h1>
<table>
    <tr>
        <th>Id</th>
        <th>Title</th>
        <th>Created</th>
    </tr>

    <!-- Here is where we loop through our $posts array, printing out post info -->

    <?php foreach ($posts as $post): ?>
    <tr>
        <td><?php echo $post['Post']['id']; ?></td>
        <td>
            <?php echo $this->Html->link($post['Post']['title'], array('controller' => 'posts', 'action' => 'view', $post['Post']['id'])); ?>
        </td>
        <td><?php echo $post['Post']['created']; ?></td>
    </tr>
    <?php endforeach; ?>

</table>

Update

CakePHP eski bir sürümünü kullanarak dışarı açar.

0 Cevap