Home > database >  Child page extends base.html.twig BUT content of base.html.twig is not rendered
Child page extends base.html.twig BUT content of base.html.twig is not rendered

Time:12-18

I am working with sulu cms and symfony. Just started with the project. This is my base.html.twig

<!DOCTYPE html>
<html lang="{{ app.request.locale|split('_')[0] }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

{% block meta %}
    {% include "@SuluWebsite/Extension/seo.html.twig" with {
        "seo": extension.seo|default([]),
        "content": content|default([]),
        "localizations": localizations|default([]),
        "shadowBaseLocale": shadowBaseLocale|default(),
    } %}
{% endblock %}

{% block style %}{% endblock %}
</head>
<body>
<header>
    {% block header %}
        <nav>
        </nav>
    {% endblock %}
</header>

<form action="{{ path('sulu_search.website_search') }}" method="GET">
    <input name="q" type="text" placeholder="Search"/>
    <input type="submit" value="Go"/>
</form>

<main>
    {% block content %}{% endblock %}
</main>

<footer>
    {% block footer %}
        <p>Copyright {{ 'now'|date('Y') }} SULU</p>
    {% endblock %}
</footer>

{% block javascripts %}{% endblock %}
</body>
</html>

And I extend it in event.html.twig

{% extends "base.html.twig" %}

{% block content %}
<h1>This is Event Template</h1>
<h1>{{ content.title }}</h1>
<h2>{{ content.subtitle }}</h2>

{% for image in content.photo %}
    <img src="{{ image.thumbnails['500x'] }}" alt="{{ image.title }}" title="{{ image.description|default(image.title) }}">
{% endfor %}
{% endblock %}

But the rendered page only shows the child content

<h1>This is Event Template</h1>
<h1>Veranstaltungstitel</h1>
<h2></h2>

What could be the reason, that the parent base template is not rendered? Could not find anything like this with google.

UPDATE

I am on a Windows 10 Pro computer and I cloned a git repository with a sulu cms / symfony project that someone else made on a Linux system.

I changed the .env file to APP_ENV=dev

I am running the project on Apache (MAMP) and with a mysql (MAMP) database. The database is connected, I can see the data in the admin panel and see changed data in the database with phpmyadmin.

On my computer Symfony CLI version v4.26.11 is installed.

CodePudding user response:

Did you create the sulu project using the create-project command like in the docs. Then you should be under dev environment. Check that by go into your local .env.local and check if there it is set to APP_ENV=dev so changes will automatically be detected and no cache clear is required. This is for development only!!!

If you are on a prod server make sure the clear all cache. This includes admin and website cache:

bin/adminconsole cache:clear
bin/website cache:clear

If that still does not help check if any edit of a twig template does effect anything in your frontend. Try also to remove all caches by removing the var/cache directory:

rm -rf var/cache

If that is not the case its a hint that your machine or server has opcache activated and all your PHP files are cached. If you are on a development machine you should configure opcache to check for file timestamps see:

https://www.php.net/manual/de/opcache.configuration.php#ini.opcache.validate-timestamps

If you are on production server where it does restart your webserver and/or php processes or use a cachetool like:

https://github.com/gordalina/cachetool

To clear that caches.

CodePudding user response:

The reason that the base.html.twig page was not rendered was an error in the theme. After deleting the theme files the page is rendered okay.

  • Related