Skip to content

Instantly share code, notes, and snippets.

@webdevilopers
Last active August 29, 2015 14:09
Show Gist options
  • Save webdevilopers/ec00181fd4b2aee772e4 to your computer and use it in GitHub Desktop.
Save webdevilopers/ec00181fd4b2aee772e4 to your computer and use it in GitHub Desktop.
Override FOSUserBundle resp. SonataUserBundle resp. ApplicationSonataUserBundle layout.html.twig template
{% extends "TwigBundle::layout.html.twig" %}
{% block head %}
<link rel="icon" sizes="16x16" href="{{ asset('favicon.ico') }}" />
{% block stylesheets %}
<link rel="stylesheet" href="/bundles/sonatacore/vendor/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ asset('/bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css') }}" />
<link rel="stylesheet" href="/bundles/sonatacore/vendor/components-font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/bundles/sonatacore/vendor/ionicons/css/ionicons.min.css">
<link rel="stylesheet" href="/bundles/sonatacore/vendor/select2/select2.css">
<link rel="stylesheet" href="/bundles/sonatacore/vendor/select2/select2-bootstrap.css">
{% endblock %}
{% block javascripts %}
<script src="/bundles/sonatacore/vendor/jquery/dist/jquery.min.js" type="text/javascript"></script>
<script src="/bundles/sonatacore/vendor/moment/min/moment.min.js"></script>
<script src="/bundles/sonatacore/vendor/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/bundles/sonatacore/vendor/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<script src="/bundles/sonatacore/vendor/select2/select2.min.js"></script>
{% endblock %}
{% endblock %}
{% block title 'Acme Demo' %}
{% block body %}
{% if is_granted('ROLE_PREVIOUS_ADMIN') %}
<a href="{{ path('default', {'_switch_user': '_exit'}) }}">Exit impersonation</a>
{% endif %}
{% for flashMessage in app.session.flashbag.get('notice') %}
<div class="flash-message">
<em>Notice</em>: {{ flashMessage }}
</div>
{% endfor %}
{% block content_header %}
<ul id="menu">
{% block content_header_more %}
<li><a href="{{ path('default') }}">Home</a></li>
{% endblock %}
</ul>
<div style="clear: both"></div>
{% endblock %}
<div class="block">
{% block content %}
{% endblock %}
</div>
{% if code is defined %}
<h2>Code behind this page</h2>
<div class="block">
<div class="symfony-content">{{ code|raw }}</div>
</div>
{% endif %}
{% endblock %}
{% extends 'AcmeDemoBundle::layout.html.twig' %}
{% block content %}
Override Layout in /app/Resources/ApplicationSonataUserBundle/views/layout.html.twig
{% block fos_user_content %}
Login
{% endblock %}
{% endblock %}
{#{% extends "FOSUserBundle::layout.html.twig" %}#}
{% block fos_user_content %}
Hide Register Link
{# {% include "FOSUserBundle:Registration:register_content.html.twig" %}#}
{% endblock fos_user_content %}
{#{% extends "SonataUserBundle:Profile:action.html.twig" %}#}
{% extends 'AcmeDemoBundle::layout.html.twig' %}
{#{% block sonata_profile_content %}#}
{% block content %}
<h2>{% block sonata_profile_title %}{% trans from 'SonataUserBundle' %}sonata_profile_title{% endtrans %}{% endblock %}</h2>
<div class="sonata-user-show row row-fluid">
<div class="span2 col-lg-2" style="padding: 8px 0;">
{% block sonata_profile_menu %}
{{ sonata_block_render({'type': 'sonata.user.block.menu'}, {'current_uri': app.request.requestUri}) }}
{% endblock %}
</div>
<div class="span10 col-lg-10">
{% include 'SonataCoreBundle:FlashMessage:render.html.twig' %}
{% block sonata_profile_content '' %}
</div>
</div>
{# {% block fos_user_content %}
{% endblock %}
#}
/app/Resources/ApplicationSonataUserBundle/views/Profile/show.html.twig
<div class="row row-fluid">
{% set has_center = false %}
{% for block in blocks %}
{% if block.position == 'center' %}
{% set has_center = true %}
{% endif %}
{% endfor %}
<div class="{% if has_center %}span4 col-lg-4{% else %}span6 col-lg-6{% endif %}">
{% for block in blocks %}
{% if block.position == 'left' %}
{{ sonata_block_render({ 'type': block.type, 'settings': block.settings}) }}
{% endif %}
{% endfor %}
</div>
{% if has_center %}
<div class="span4 col-lg-4">
{% for block in blocks %}
{% if block.position == 'center' %}
{{ sonata_block_render({ 'type': block.type, 'settings': block.settings}) }}
{% endif %}
{% endfor %}
</div>
{% endif %}
<div class="{% if has_center %}span4 col-lg-4{% else %}span6 col-lg-6{% endif %}">
{% for block in blocks %}
{% if block.position == 'right' %}
{{ sonata_block_render({ 'type': block.type, 'settings': block.settings}) }}
{% endif %}
{% endfor %}
</div>
</div>
{% endblock %}
@webdevilopers
Copy link
Author

Issue "Various nesting problems when overriding FOSUserBundle resp. SonataUserBundle resp. ApplicationSonataUserBundle layout template": sonata-project/SonataUserBundle#449

The login OK:
bildschirmfoto vom 2014-11-14 13 37 37

The Password Reset OK:
bildschirmfoto vom 2014-11-14 13 37 46

The Profile Show OK:
bildschirmfoto vom 2014-11-14 13 39 24

The Profile Edit !OK:
bildschirmfoto vom 2014-11-14 13 40 11

The Authentication Edit !OK:
bildschirmfoto vom 2014-11-14 13 40 25

This issue is possibly related to:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment