Have problem displaying information via Twig template.
I'm using Twig Template
, AltoRouter
.
AltoRouter code:
$router->map('GET','/[*]','Edion\Controllers\QuestionController@showCountMessage'
,'count_message');
Controller:
public function showCountMessage() {
$message = InsideMessage::where('author_id', '=', $_SESSION['user']['id'])
->where('author_read', '=', '0')->get();
echo $this->twig->render('topnav.html.twig', ['messages' => count($message)]);
}
topnav.html.twig are included in all my pages
The problem is that I don't get number of messages in my website. If I change AltoRouter code:
$router->map('GET','/example','Edion\Controllers\QuestionController@showCountMessage'
,'count_message');
And I enter sitename.com/example
it work's perfectly, but when I change to [*]
because I want that this information would be on all of my pages, don't work.
Maybe someone knows how to solve this problem?
Remove $router and echo from showCountMessage(). Add twig global variable.