[英]Error with urlFor() on Slim + Twig
我在Slim說的地方出錯
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>
視圖和模型的代碼
$app->get('/users', function() use ($app, $authorized,$users)
{
$app->render('users.twig',array('users' => $users, 'is_admin' => $authorized));
})->name('userList');
github中的代碼是=> https://github.com/Mangulomx/olimpiada
在我看來,您沒有在項目的任何地方加載users.php路由文件。 如果未加載,則錯誤是正確的,因為基於加載的路由它不知道該路由。 您可能需要將../routes/users.php添加到public / index.php中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.