I have 2 Entities: Clinic, Vet, for which I created CRUD templates with app/console generate:doctrine:crud
I first created the Clinic entity and created my "admin template" in AgriHealth/AhpBundle/Resources/views/admin.html.twig and then extend this in
AgriHealth/AhpBundle/Resources/views/Clinic/index.html.twig:
{% extends 'AgriHealthAhpBundle::admin.html.twig' %}
This worked.
Then I created Entity Vet and ran the crud generator. Again I'm extending:
AgriHealth/AhpBundle/Resources/views/Vet/index.html.twig:
{% extends 'AgriHealthAhpBundle::admin.html.twig' %}
But this seems to be ignored, as the layout from my admin template doesn't come through. I have tried:
- app/console cache:clear
- renaming admin.html.twig: causes an error in both views as expected
I must be missing something? Any ideas?
Twig code below:
src/AgriHealth/AhpBundle/Resources/views/admin.html.twig
{% extends '::base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link href="{{ asset('bundles/agrihealthahp/css/admin.css') }}" rel="stylesheet" />
<link href="{{ asset('bundles/agrihealthsecurity/css/admin.css') }}" rel="stylesheet" />
{% endblock %}
{% block body -%}
<div class="row" id="header">
<div class="small-12 columns">
<h1><a href=""><img src="/bundles/agrihealthahp/images/agrihealth-logo.png" />
<span>Animal Health Planner</span></a></h1>
</div>
</div>
<div class="row" id="menu">
<div class="small-12 columns">
</div>
</div>
<div class="row" id="content">
<div class="small-12 columns">
{% block admin %}{% endblock %}
</div>
</div>
<div class="row" id="black_footer">
<div class="small-12 medium-5 columns footer-black-1">
<div class="moduletable">
<div class="custom">
<p><a href="http://www.agrihealth.co.nz">www.agrihealth.co.nz</a></p></div>
</div>
</div>
<div class="small-12 medium-7 columns ">
<div class="left footer-black-2">
<div class="moduletable">
<div class="custom">
<p>0800 821 421</p></div>
</div>
</div>
<div class="right footer-black-3">
<div class="moduletable">
<div class="custom">
<p><sup></sup><sup><img style="line-height: 1.1;" src="/bundles/agrihealthahp/images/agrihealth_white.png" alt="agrihealth white"></sup></p></div>
</div>
</div>
</div>
</div>
{% endblock %}
src/AgriHealth/AhpBundle/Resources/views/Clinic/index.html.twig:
{% extends 'AgriHealthAhpBundle::admin.html.twig' %}
{% block admin -%}
<h1>Clinics</h1>
<ul class="actions">
<li>
<a href="{{ path('clinic_new') }}">
Add Clinic
</a>
</li>
</ul>
<table class="records_list">
<thead>
<tr>
<th>Name</th>
<th>Phone</th>
<th>Fax</th>
<th>After Hours</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td><a href="{{ path('clinic_show', { 'id': entity.id }) }}">{{ entity.name }}</a></td>
<td>{{ entity.phone }}</td>
<td>{{ entity.fax }}</td>
<td>{{ entity.afterhours }}</td>
<td>{{ entity.email }}</td>
<td>
<ul class="actions">
<li>
<a href="{{ path('clinic_edit', { 'id': entity.id }) }}">edit</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
src/AgriHealth/AhpBundle/Resources/views/Vet/index.html.twig:
{% extends 'AgriHealthAhpBundle::admin.html.twig' %}
{% block body -%}
<h1>Vets</h1>
<ul class="actions">
<li>
<a href="{{ path('vet_new') }}">
Add Vet
</a>
</li>
</ul>
<table class="records_list">
<thead>
<tr>
<th>Name</th>
<th>Mobile</th>
<th>Clinic</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td><a href="{{ path('vet_edit', { 'id': entity.id }) }}">{{ entity.firstname }} {{ entity.lastname }}</td>
<td>{{ entity.mobile }}</td>
<td><a href="{{ path('clinic_edit', { 'id': entity.id }) }}">{{ entity.clinic }}</a></td>
<td>
<ul class="actions">
<li>
<a href="{{ path('vet_edit', { 'id': entity.id }) }}">edit</a>
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
MyBundleAppBundle:Vet:index.html.twig
, then again you may not but without seeing a bit more of the templates it's hard to guess. Best bet would be to stick some of your template data up and see where that goes. – qooplmaoAgriHealth/AhpBundle/Resources/views/admin.html.twig
page up twice, what the code forAgriHealth/AhpBundle/Resources/views/Clinic/index.html.twig
? – qooplmao