[英]Phalcon not rending view action when using router
I have a problem with Phalcon PHP. 我的Phalcon PHP有问题。 It cannot display the view of an action of a controller when using with routing
与路由一起使用时,它无法显示控制器动作的视图
Ex: http://vngarena.com/game/kieu-hung-2472.html 例如: http : //vngarena.com/game/kieu-hung-2472.html
The result just displayed the text from gamedetail action: "This is gamedetail Action", not the title of the game in the view. 结果仅显示来自gamedetail动作的文本:“这是gamedetail动作”,而不是视图中游戏的标题。
app/config/routes.php
: 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() }}
Things to check: 检查事项:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.