After I edit my twig templates, they don’t load on the page.
I have a header and footer twig file which are included in my base.html.twig. When i edit these files, the changes aren’t pushed trough when i reload the page. I’ve tried clearing the cache and i disabled cache in configpackagestwig.yaml
I even tried to completely delete the cache folder, nothing seems to work.
I use the built in Symfony server.
homepageController.php:
?php namespace AppController; use SymfonyBundleFrameworkBundleControllerAbstractController; use SymfonyComponentRoutingAnnotationRoute; use SensioBundleFrameworkExtraBundleConfigurationTemplate; use AppEntityVacature; /** * @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); } }
Homepage/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>
the tree is
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
Edit: I thought maybe this could be the reason somehow, the entire folder was inside my OneDrive. The thought crossed my mind, OneDrive is to blame. I don’t know why, it’s just a hunch…
Advertisement
Answer
Well… I just restarted the whole project. There were several other problems with it. Although it would be interesting to see if anyone knows why the header an footer didn’t change, it is not really relevant anymore.