2016-06-24 3 views
1

特定のURLのChildPage.phpという名前のビューファイルをレンダリングしたいとします。... /index.php?r=site%2FChildPageYii2でアクションを作成/アクセスする方法は?

私は小さなビューを書いて、私のSiteControllerクラスにメソッドを追加しました:

public function actionChildPage() 
    { 
     return $this->render('ChildPage'); 
    } 

は、私が何かを忘れてしまいましたか?すべての私の他のページが働いているが、このページでは、私はエラーを取得:

Not Found (#404) 
Page not found. 

答えて

0

読むよりおよそcreating actions

By default, action IDs should contain these characters only: English letters in lower case, digits, underscores, and hyphens. (You can use hyphens to separate words.) For example, view, update2, and comment-post are all valid action IDs, while view? and Update are not.

The names of the action methods are derived from action IDs according to the following procedure:

  • Turn the first letter in each word of the action ID into upper case.
  • Remove hyphens.
  • Prepend the prefix action.

あなたは、単に次のルートを使用する必要がありますsite/child-page

関連する問題