【发布时间】:2021-02-24 13:54:30
【问题描述】:
编辑树枝模板后,它们不会加载到页面上。
我的 base.html.twig 中有一个页眉和页脚树枝文件。 当我编辑这些文件时,当我重新加载页面时,这些更改不会被推送。 我尝试清除缓存并在 config\packages\twig.yaml
中禁用缓存我什至尝试完全删除缓存文件夹,但似乎没有任何效果。
我使用内置的 Symfony 服务器。
主页控制器.php:
?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use App\Entity\Vacature;
/**
* @Route("/")
*/
class HomepageController extends AbstractController
{
/**
* @Route("/", name="homepage")
* @Template()
*/
public function index()
{
$rep = $this->getDoctrine()->getRepository(Vacature::class);
$data1 = $rep->getAllVacatures();
$data2 = $rep->getLastVacatures(5);
return array("carousel" => $data1, "laatste5" => $data2);
}
}
主页/index.html.twig
{% extends 'base.html.twig' %}
{% block title %}Hello HomepageController!{% endblock %}
{% block body %}
{% for vacature in carousel %}
<div class="vacature">
<h4>{{ vacature.titel }}</h4>
<p>{{ vacature.tekst }}
<a href="{{ path('vacature', { "id": vacature.id}) }}">Bekijk</a>
</div>
{% endfor %}
{% for vacature in laatste5 %}
<div class="vacature">
<h4>{{ vacature.titel }}</h4>
<p>{{ vacature.tekst }}
<a href="{{ path('vacature', { "id": vacature.id}) }}">Bekijk</a>
</div>
{% endfor %}
<pre>
{{ dump(carousel) }}
</pre>
{% endblock %}
base.html.twig
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}VacIT{% endblock %}</title>
<link href="{{ asset('/assets/css/foundation.css') }}" rel="stylesheet"/>
<link href="{{ asset('/assets/css/main.css') }}" rel="stylesheet"/>
{% block stylesheets %}{% endblock %}
</head>
<body>
<div id='header'>
{% include "header.html.twig" %}
</div>
{% block body %}{% endblock %}
{% block javascripts %}{% endblock %}
<div id='footer'>
{% include "footer.html.twig" %}
</div>
</body>
</html>
header.html.twig
<div class='header'>
<div class="row">
<div class="small-12 columns">
<div class='header-logo'>
<a href="{{ path('homepage') }}">
<img id='logo' src="{{ asset('/assets/images/logo/logo.png') }}" alt="logo" width="200px">
</a>
</div>
<div class="skew-header-shadow">
<div class="skew-header"> </div>
</div>
</div>
</div>
</div>
footer.html.twig
<div class="footer-box">
<div class="skew-footer-shadow">
<div class="skew-footer"> </div>
</div>
<div class="footer">
<a href="{{ path('homepage') }}">
<img id='logo' src="{{ asset('/assets/images/logo/logo.png') }}" alt="logo" width="300px">
</a>
</div>
</div>
树是
Project
|-bin
|-config
|-public
|-assets
|-CSS
|-Fonts
|-images
|-logo
|-src
|-Command
|-Controller
|-Entity
|-Repository
|-Resources
|-templates
|-homepage
|-index.html.twig
base.html.twig
header.html.twig
footer.html.twig
编辑:我认为这可能是某种原因,整个文件夹都在我的 OneDrive 中。我的脑海里闪过这个想法,OneDrive 是罪魁祸首。我不知道为什么,这只是一种预感......
【问题讨论】:
-
尝试在浏览器的开发者控制台中勾选“禁用缓存”选项。可能是 http 缓存的问题。
-
在 DevTools(Edge) 打开时缓存被禁用,即使尝试其他浏览器也无济于事。
-
您是否尝试过使用不同的网络服务器?这可能有助于缩小问题范围
-
发布代码(所有树枝文件和控制器)。还要发布您的目录树。你有什么输出?
-
它输出旧版本的页眉和页脚树枝文件,例如徽标文件和文件夹有一个大写字母。如何发布输出?