2

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?

Kintamasis
  • 265
  • 6
  • 27
  • I found the solution to this problem. Remove $router and echo from showCountMessage(). Add twig global variable and it's all working perfectly. – Kintamasis Mar 11 '16 at 15:01
  • You can add an answer and accept it: http://stackoverflow.com/help/self-answer – A.L Mar 11 '16 at 20:02

1 Answers1

0

Remove $router and echo from showCountMessage(). Add twig global variable.

Kintamasis
  • 265
  • 6
  • 27