1

Phalcon PHP がそのビューをレンダリングする方法について、私は完全に混乱しています。「マネージャー」という新しいページを作成したいと考えています。

コントローラーを作成することによる私の理解から、それをビューにリンクできます。というコントローラーを作成しManagerController.php、 にビューを追加しましたviews/manager/index.volt

動作するかどうかを確認するために、ボルトファイルに少しテキストを追加しました。私が行くと/manager/何も表示されません。

私はこれを正しく行っていますか、それともどこかにビューを割り当てる必要がありますか?

class ManagerController extends ControllerBase
{
    public function initialize()
    {
        $this->tag->setTitle('Files/My Files');
        parent::initialize();
    }
}
4

1 に答える 1

2

コントローラーの初期化関数は、コントローラーの構築後に実行されるイベントです

そのコントローラのビューを表示するには、少なくとも index アクションを設定する必要があります

/manager/ のルートのレンダリングに関心がある場合、これは indexAction に対応します。

class ManagerController extends ControllerBase
{
    public function initialize()
    {
        $this->tag->setTitle('Files/My Files');
        parent::initialize();
    }
    public function indexAction()
    {
        // This will now render the view file located inside of
        // /views/manager/index.volt

        // It is recommended to follow the automatic rendering scheme
        // but in case you wanted to render a different view, you can use:
        $this->view->pick('manager/index');
        // http://docs.phalconphp.com/en/latest/reference/views.html#picking-views
    }

    // If however, you are looking to render the route /manager/new/
    // you will create a corresponding action on the controller with RouteNameAction:
    public function newAction()
    {
        //Renders the route /manager/new
        //Automatically picks the view /views/manager/new.volt
    }
}
于 2015-01-18T16:58:13.763 に答える