[已解决] 我有 Symfony 应用程序,我正在使用树枝模板。当我在我的计算机上本地运行我的应用程序时,它可以工作,但是当我将它上传到我的托管服务提供商的某些页面上时<meta charset="UTF-8" />
,<title>
head和标签进入正文。这只发生在一些树枝模板上,而不是全部。这是我的基本模板
<!DOCTYPE html>
<html>
{% block head %}
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
{% block stylesheets %}{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head>
{% endblock %}
<body>
<nav>
<div class="container">
{% if app.user %}
<a href="{{ path('user_logout') }}">Изход</a>
<a href="{{ path('zadanie_index') }}">Заявки</a>
{% if (app.user.type == "Manager") or (app.user.type == "LittleBoss") %}
<a href="{{ path('zadanie_new') }}">Нова заявка</a>
{% endif %}
{% else %}
<a href="{{ path('homepage') }}">Home</a>
<a href="{{ path('user_login') }}">Вход</a>
{% endif %}
</div>
</nav>
{% block body %}{% endblock %}
{% block javascripts %}{% endblock %}
</body>
</html>
它是一个有效的 html,它可以工作。每个视图都扩展了 base 和 overrides block body
,这就是它们所做的一切。这是我new.html.twig
在本地和服务器上都可以使用的
{% extends 'base.html.twig' %}
{% block body %}
<h1>Нова заявка</h1>
{{ form_start(form) }}
{{ form_widget(form) }}
<input type="submit" value="Create" />
{{ form_end(form) }}
<ul>
<li>
<a href="{{ path('zadanie_index') }}">Върни се към списъка със заявки</a>
</li>
</ul>
{% endblock %}
非常简单 - 它扩展了 base 并覆盖了块体,就是这样。现在这里是index.html.twig
元标记进入正文的代码。请记住,这两个文件都在同一个文件夹中,并且它们扩展了同一个基本文件。
{% extends 'base.html.twig' %}
{% block body %}
<h1>Заявки</h1>
<table>
<thead>
<tr>
<th>Отдел</th>
<th>От</th>
<th>Вид</th>
<th>Описание</th>
<th>Краен Срок</th>
<th>Дата</th>
<th>Дизайнер</th>
<th>Подизпълнител</th>
<th>Приключил</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for zadanie in zadanies %}
<tr style="background-color:{{ zadanie.backgroundColor }}">
<td>{{ zadanie.department }}</td>
<td>{{ zadanie.fromUser }}</td>
<td>{{ zadanie.typeTask }}</td>
<td>{{ zadanie.description }}</td>
<td>{% if zadanie.term %}{{ zadanie.term|date('Y-m-d H:i:s') }}{% endif %}</td>
<td>{% if zadanie.date %}{{ zadanie.date|date('Y-m-d H:i:s') }}{% endif %}</td>
<td>{{ zadanie.designer }}</td>
<td>{{ zadanie.executioner }}</td>
<td>{% if zadanie.isOver %}Yes{% else %}No{% endif %}</td>
<td>
<ul>
<li>
<a href="{{ path('zadanie_show', { 'id': zadanie.id }) }}">show</a>
</li>
<li>
<a href="{{ path('zadanie_edit', { 'id': zadanie.id }) }}">edit</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul>
<li>
<a href="{{ path('zadanie_new') }}">Създай нова заявка</a>
</li>
</ul>
{% endblock %}
有些部分是用保加利亚语(西里尔文)写的,你可能看不懂,但这与逻辑无关。它们纯粹是静态的。该文件再次扩展了 base 并覆盖了 body。出于某种原因,当我在服务器上运行这段代码时,我得到的是:
这是我在本地运行时得到的结果:
The code is the same. And if you are asking about the server - they told me they are not familiar with Symfony and can't help me with my problem. So I just know they have PHP 7.1 and can run Symfony app and I also know something is broken. If you can't help me fix it by changing the code please tell me what should I say to my hosting provider
Turned out i had a dump() in my controller and for some reason it broke everything
As stated in the comments I had a dump() which broke everything. Removed it and it was all gucci.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句