Twig template error

  1. 2 years ago

    Dave

    27 Nov 2014 Administrator

    Hi
    Any idea why I am getting this error from a template I have uploaded please?

    A template that extends another one cannot have a body in "default.twig" at line 2.

    My default.twig looks like this, (no body tag in there)

    {% extends "layout.twig" %}
    
    
    <div id="main-content" class="main-content">
    
    
    
        <div id="primary" class="content-area">
            <div id="content" class="site-content" role="main">
    
            {{widget('blogpostlist', 'blogpostlist_widget', {})|raw}}
    
            </div><!-- #content -->
        </div><!-- #primary -->
        
    </div><!-- #main-content -->

    - charliefortune

    Hi there,

    You need to wrap your markup in a twig 'content block'. Checkout this example:

    {% extends "layout.twig" %}
    {% block content %}
    <div id="main-content" class="main-content">
        <div id="primary" class="content-area">
            <div id="content" class="site-content" role="main">
            {{widget('blogpostlist', 'blogpostlist_widget', {})|raw}}
            </div><!-- #content -->
        </div><!-- #primary -->
    </div><!-- #main-content -->
    {% endblock %}

    Try this in your template and let us know how you get on.

  2. Dave

    27 Nov 2014 Administrator Answer

    Hi there,

    You need to wrap your markup in a twig 'content block'. Checkout this example:

    {% extends "layout.twig" %}
    {% block content %}
    <div id="main-content" class="main-content">
        <div id="primary" class="content-area">
            <div id="content" class="site-content" role="main">
            {{widget('blogpostlist', 'blogpostlist_widget', {})|raw}}
            </div><!-- #content -->
        </div><!-- #primary -->
    </div><!-- #main-content -->
    {% endblock %}

    Try this in your template and let us know how you get on.

or Sign Up to reply!