我正在尝试在 kohana 中集成分页,但不知道发生了什么。我收到这些错误“Undefined variable: pager”

I am trying to integrate pagination in kohana, but don't know what is happening. I get these error " Undefined variable: pager"

试图在 kohana 3.3 中集成分页,但在集成后出现这些错误 "ErrorException [ Notice ]: Undefined variable: pager" 以下是我的控制器:`

class Controller_Welcome extends Controller_Application
{

    public function action_index()
    {

        $content = View::factory('welcome')
        ->bind('messages', $messages);
        $message = new Model_Message;
        $message_count = $message->count_all();
        $pagination = Pagination::factory(array(
        'total_items' => $message_count,
        'items_per_page' => 3,
        ));
        $pager = $pagination->render();
        $messages = $message->get_all($pagination->items_per_page,$pagination->offset);
        $this->template->content = $content;
    }

} // End Welcome

视图是

<h1>Recent Messages on Egotist</h1> 
<?php foreach ($messages as $message) : ?>
    <p class="message"> <?php echo $message['content']; ?> <br/>
        <span class="published">
            <?php echo Date::fuzzy_span($message['date_published']) ?>
        </span>
    </p>
    <hr/>
<?php endforeach; ?> <?php echo $pager; ?>

您需要将 $pager 绑定到您的视图:

$content = View::factory('welcome')
    ->bind('messages', $messages)
    ->bind('pager', $pager);