我一直在尝试像这样扩展树枝模板:
{% extends 'OpenSkedgeBundle:Dashboard:index.html.twig' %}
{% block modulecontent %}
<ul id="Groups">
{% for entity in entities %}
<li>{{ entity.groupwork }}</a></li>
{% endfor %}
</ul>
{% endblock %}
我这样称呼视图:
return $this->render('OpenSkedgeBundle:GroupWork:view.html.twig', array(
'entities' => $entity,
));
根据堆栈跟踪:
在Twig_Template-> displayWithErrorHandling(array('entities'=> array(object(GroupWork),object(GroupWork),object(GroupWork)),
'assetic'=> array('debug'=> true,'vars'=> object(ValueContainer), 'use_controller'=> true),'app'=> object(AppVariable),
'deploy_commit'=>''),数组('modulecontent'=>
数组(object(__ TwigTemplate_5759d43e3302350280503ee495baef2b7320e0a944bb3e9ca5ba21b179072690), 'block_modulecontent'))) 在/home/tenga/Documents/OpenSkedge-1.2.x-dev/app/cache/dev/classes.php
中 5307行在Twig_Template-> display(array('entities'=> array(object(GroupWork),object(GroupWork),object(GroupWork))))) 在/home/tenga/Documents/OpenSkedge-1.2.x-dev/app/cache/dev/classes.php
中 第5314行根据数据,看来base.html.twig是
错误的:
这是base.html.twig
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="robots" content="noindex,nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{% block title %}{{ app_brand_name() }} - {{ get_controller_name()|capitalize }} {% if get_action_name() != 'index' and get_action_name() != 'view' %}- {{ get_action_name()|capitalize }}{% endif %}{% endblock %}</title>
<link rel="icon" href="{{ asset('favicon.ico') }}" type="image/x-icon" />
<link href="//fonts.googleapis.com/css?family=Lato:400,700,400italic" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/bootstrap-todc.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/bootstrap-responsive.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/select2-todc.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/application.css') }}" rel="stylesheet" type="text/css" />
{% spaceless %}{% block stylesheets %}{% endblock %}{% endspaceless %}
</head>
<body>
{% block content %}{% endblock %}
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
<script src="{{ asset('js/jquery.tablesorter.min.js') }}"></script>
<script src="{{ asset('js/jquery.tablesorter.widgets.min.js') }}"></script>
<script src="{{ asset('js/select2.min.js') }}"></script>
<script src="{{ asset('js/application.js') }}"></script>
{% spaceless %}{% block javascripts %}{% endblock %}{% endspaceless %}
<footer>
<div class="container-fluid">
<p class="muted credit">Powered by <a href="http://www.openskedge.org"><i class="openskedge-logo-blue"></i>OpenSkedge</a> · Copyright © 2012-{{ "now"|date("Y") }} OpenSkedge contributors · Licensed under the GNU GPL version 3 · <a href="https://github.com/maxfierke/OpenSkedge/issues">Report a bug</a> <small class="muted pull-right text-right">{% if deploy_commit != null %}commit {{ deploy_commit }}{% endif %}</small><div class="clearfix"></div></p>
</div>
</footer>
</body>
</html>
在第7行,我只能使用这些树枝变量,这些变量主要与网页的样式有关
据此:
src / OpenSkedge / AppBundle / Twig / Extension / PageExtension.php在线 45
$matches = array();
preg_match($pattern, $this->request->get('_controller'), $matches);
return strtolower($matches[1]);
}
在比赛$pattern = "#Controller\\\([a-zA-Z]*)Controller#";
我发现了失败的原因: 因为它将控制器返回为 OpenSkedge \ AppBundle \ Controller \ UserController :: viewAction
代替 OpenSkedgeBundle:GroupWork:view
我的问题我该如何更改?