2016-02-17 44 views
0

我得到一个错误的修身说错误与超薄+嫩枝urlFor()

Message: An exception has been thrown during the rendering of a template 
("Named route not found for name: userList") in "sidebar.twig" at line 7. 

我的看法是

{% extends 'base.twig' %} 
{% block title %} Índice {% endblock title %} 

{% block content %} 
<div class="row"> 
    <div class="container"> 
    {% include "sidebar.twig" %} 

我的看法是sidebar.twig如下:

<div class="col-lg-4 col-md-4 col-xs-4"> 
    <div class="dropdown menu col-lg-9 col-md-9 col-xs-9"> 
     <ul class="nav nav-pills nav-stacked"> 
      <li><a tabindex="-1" href="#">GESTIÓN DE PARTICIPANTES</a></li> 
      {% if authorized %} 
      <li><a tabindex="-1" href="{{ urlFor('userList') }}">GESTION DE USUARIOS</a></li> 
      {% endif %} 
     </ul> 
    </div> 
</div> 

code for view + model

在github上
$app->get('/users', function() use ($app, $authorized,$users) 
{ 
    $app->render('users.twig',array('users' => $users, 'is_admin' => $authorized)); 
})->name('userList'); 

代码是=>https://github.com/Mangulomx/olimpiada

+0

检查您的路线文件是否定义了路线名'userList'?显示代码从路线文件 –

+0

我显示$ app-> get('/ users',function()use($ app,$ authorized,$ users) { $ app-> render('users.html.twig ',array('users'=> $ users,'is_admin'=> $ authorized)); }) - > name('userList'); – mangulom

+0

请检查http://help.slimframework.com/discussions/problems/943-cant-get-twig-extensions-to-work此回复发布者Brian Nesbitt于2012年9月29日@ 08:44 AM –

回答

1

它看起来对我来说,你是不是在你的项目中的任何地方加载users.php路由文件。如果没有加载,那么错误是正确的,因为它不知道基于加载的路由的路线。您可能需要将../routes/users.php添加到public/index.php。