【发布时间】:2014-03-31 15:39:12
【问题描述】:
我遇到了 Phalcon PHP 的问题。与路由一起使用时无法显示控制器动作的视图
例如:http://vngarena.com/game/kieu-hung-2472.html
结果只是显示了来自 gamedetail action 的文本:“This is gamedetail Action”,而不是视图中的游戏标题。
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() }}
【问题讨论】:
标签: view routes action phalcon