繁体   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