1
votes

I'm working on a Symfony site, v 2.8.3. I have controllers and twig files all set up.

Every page I go to I get the default welcome screen.

The Symfony profiler shows the correct twig file but doesn't render it.

Any suggestions?

In DefaultController.php

 /**
 * @Route("/")
 * @Template()
 */
public function indexAction()
{

}

base.html.twig

<!DOCTYPE html>
<html>
<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>
<body>
    {% block body %}{% endblock %}
    {% block javascripts %}{% endblock %}
</body>

index.html.twig

{% extends '::base.html.twig' %}

{% block body_container_main_content %}
1
Check template rendered by your controller. Can you post some controller code to help us ? - Jérôme
You get an exception? - Arthur
Your indexAction is doing nothing, did you forget some code inside ? - Jérôme
No it supposed to load ended.html.twig, which the profiler is showing it's doing. It's just not rendering the block body content. - Jeremy
You have the body block in parent template? - Arthur

1 Answers

2
votes

You don't have body_container_main_content block in base template

Add it to body block

<!DOCTYPE html>
<html>
<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>
<body>
    {% block body %}
       {% block body_container_main_content %}{% endblock %}
    {% endblock %}
    {% block javascripts %}{% endblock %}
</body>