Question

I have a problem with 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

The result just displayed the text from gamedetail action: "This is gamedetail Action", not the title of the game in the view.

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() }}
Was it helpful?

Solution

Things to check:

  • View on the server has the correct read/write permissions
  • I think Phalcon is case sensitive for naming. Note how you've used "frontend" and "Frontend".
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top