簡體   English   中英

使用路由器時,Phalcon不發送視圖操作

[英]Phalcon not rending view action when using router

我的Phalcon PHP有問題。 與路由一起使用時,它無法顯示控制器動作的視圖

例如: http//vngarena.com/game/kieu-hung-2472.html

結果僅顯示來自gamedetail動作的文本:“這是gamedetail動作”,而不是視圖中游戲的標題。

app/config/routes.php

$router = new Phalcon\Mvc\Router();
$router->add("/game/([a-z0-9\-]+)-([0-9]+).html", array(
    'namespace' => 'Vokuro\Controllers\\',
    'controller' => 'Frontend',
    'action' => 'gamedetail',
    'slug' => 1,
    'id' => 2
))->setName("game-detail");

/app/controllers/FrontendController.php

use Vokuro\Models\Terms;
use Vokuro\Models\Games;

class FrontendController extends ControllerBase
{

    public function gamedetailAction($slug, $id) {

        echo "This is gamedetail Action";
        $game = Games::findFirstById($id);

        if (!$game) {
            $this->flash->error("Game does not exist");
        }
        else {
            $this->view->game = $game;
            $this->view->screenshots = $game->screenshot;
       }
    }

}

app/views/frontend/gamedetail.volt

{{ game.title }

app/views/layouts/frontend.volt

{{ content() }}

檢查事項:

  • 服務器上的視圖具有正確的讀/寫權限
  • 我認為Phalcon命名時區分大小寫。 請注意您如何使用“前端”和“前端”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM