mremi / ContactBundle

Provides a contact form for a Symfony project.
27 stars 23 forks source link

Can't override default template #5

Closed reypm closed 10 years ago

reypm commented 10 years ago

Hi there, I'm trying to override the default layout for your bundle but I can't since I'm still getting the same layout all the time. This is what I did:

Create a folder inside app/Resources and call it ContactBundle and create the structure as picture below shows:

7-22-2014 9-59-12 pm

Then in index.html.twig I want to extends from MopaBootstrapBundle::base.html.twig so I override the template by changing this:

{% extends 'MopaBootstrapBundle::base.html.twig' %}
{% trans_default_domain 'MremiContactBundle' %}
{% block content %}
    <div class="col-sm-9">
        {% block content_content %}
            {{ form_start(form, {'action': path('mremi_contact_form')}) }}
            <fieldset>
                <legend>{{ 'mremi_contact.form_title'|trans }}</legend>
                {{ form_widget(form) }}
            </fieldset>
            {{ form_end(form) }}
        {% endblock content_content %}
    </div>
{% endblock content %}

But content still showing with the default template:

7-22-2014 10-01-57 pm

What I'm doing wrong? Did I miss something?

mremi commented 10 years ago

Hi the folder name ContactBundle is wrong, rename it to MremiContactBundle and then you should see your template.

reypm commented 10 years ago

@mremi I did the change as you suggest, then clear the Symfony cache and the browser cache, try again and get the same result. I'm trying to extends from the override MopaBootstrapBundle that's in Resources at the same level as MremiContactBundle, any other advice?

mremi commented 10 years ago

Weird, I did it successfully: I created app/Resources/MremiContactBundle/views/Contact/index.html.twig and added lorem ipsum in the body block. I just refreshed my browser (with app_dev.php) and can see the lorem ipsum. Can you try to do the same?

mremi commented 10 years ago

Ok I just see you forgot the Contact folder in views; the good path is app/Resources/MremiContactBundle/views/Contact/index.html.twig.

reypm commented 10 years ago

Thx it's working now is just the folder structure was bad