PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, December 28, 2021

[FIXED] Child page extends base.html.twig BUT content of base.html.twig is not rendered

 December 28, 2021     sulu, symfony, twig     No comments   

Issue

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.


Solution

The reason that the base.html.twig page was not rendered was that the theme templates are overriding the default theme.



Answered By - gute Fee
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing