Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

A template that extends another one cannot have a body in "contact.twig" Need HELP!

i successfully made my index.html in to a main.twig file, and i used it as a template already, but now I'm trying to create a second template and its giving me the following error:

A template that extends another one cannot have a body in "contact.twig"

http://port-80-vz5x68xhq3.treehouse-app.com/contact

4 Answers

pi R
pi R
12,720 Points

Hi dude ! Did you delete the tags in your contact.twig file? Take a snapshot of your workspace if still in trouble ;) will be usefull for us to check your code.

{% extends 'main.twig' %}
{% block content %} 

        <!-- Main Content -->
            <section id="contact-us">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-sm-4 padding-0">
                            <div id="map"></div>
                        </div>
                        <div class="col-sm-4 padding-0 contct-middle-back">
                            <div class="contact-us-info">
                                <h2>Contact Info</h2>
                                <p>
                                    Vivamus vel lacinia eros. Aliquam porttitor sed nisi con se- 
                                    quat auctor. Praesent volutpat tortor sit amet massa tristique sollicitudin. Pellentesque elit purus, sodales at pharetra vitae, condimentum at sapien. Curabitur justo dui, ornare id diam sit amet, condimentum vestibulum 
                                </p>
                                <p class="contact-add"><span>Address:</span> Some Street 123, Manhattan, New York, USA</p>
                                <p><span>Telephone:</span><a href="tel:+001233456">  +00 123 3456</a></p>
                                <p><span>Email:</span>  <a href="mailto:info@business.com">info@business.com</a></p>
                            </div>
                        </div>
                        <div class="col-sm-4 padding-0 contct-right-back">

                            <div class="contact-form-1">
                                <h2>Send us a Message</h2>
                                <!-- Contact Form -->                            
                                <form class="form" id="contact_form" method="post" autocomplete="off">
                                    <div class="clearfix">

                                        <div class="contact-applied-form">

                                            <!-- Name -->
                                            <div class="form-group triggerAnimation animated" data-animate="fadeInRight">
                                                <label for="name"> <span class="content-red">*</span> Full Name</label>
                                                <input type="text" name="name" id="name" class="reply-info-field form-control" pattern=".{3,100}" required>
                                            </div>
                                        </div>
                                        <div class="contact-applied-form">
                                            <!-- Email -->
                                            <div class="form-group triggerAnimation animated" data-animate="fadeInRight">
                                                <label for="email"><span class="content-red">*</span>Your Email address</label>
                                                <input type="email" name="email" id="email" class="reply-info-field form-control" pattern=".{5,100}" required>
                                            </div>
                                        </div>

                                        <div class="contact-applied-form">

                                            <!-- Message -->
                                            <div class="form-group triggerAnimation animated" data-animate="fadeInRight">
                                                <label for="message">Your message (Optional):</label>
                                                <textarea rows="6" name="message" id="message" class="reply-info-area form-control"></textarea>
                                            </div>

                                        </div>

                                    </div>

                                    <!-- Send Button -->
                                    <button class="submit_btn btn btn-mod btn-large btn-full contact-submit-btn-1 triggerAnimation animated" data-animate="bounceIn" id="submit_btn_2">
                                        apply now
                                    </button>

                                    <div id="result"></div>

                                </form>
                            </div>
                        </div>
                    </div>
            {% endblock content %}  </div>
            </section>
        <!--/ End Main Content -->

Formatted code quote.

sorry the extends code is sticking out but thats my current code for contact.twig

pi R
pi R
12,720 Points

Try to put your endblock AFTER the section closing tag.

got it fixed! I missed out on removing the classes before, which were already on the main.twig.Thanks mate!

Please post your fixed code for future reference.