DamienHarper/auditor-bundle

Customizing the views

IpelaTech opened this issue · 2 comments

Hi

I'd like to find out, is it possible to use my theme/layout or base.html.twig file for the views? We're developing for a client and they'd like their logo etc on the audit log views. I've tried the different ways to extend/override templates from the Symfony documentation but I'm not getting the result I need.

Is there any way of achieving this?

Hi @IpelaTech, you can override auditor-bundle templates by following Symfony documentation.

Below is an example of a modified version of the default auditor-bundle layout with a Symfony logo (and link) instead of the default one.
Just save it in /PATH-OF-YOUR-PROJECT/templates/bundles/DHAuditorBundle/layout.html.twig

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>auditor</title>
    {% block stylesheets %}
        <link rel="stylesheet" href="{{ asset('bundles/dhauditor/app.css') }}">
    {% endblock %}
</head>
<body>
<div>
    <nav class="bg-gray-200 py-2">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex items-center justify-between h-16">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <!-- Symfony link and logo -->
                        <a href="https://www.symfony.com" class="navbar-brand mb-0 text-light" title="auditor" style="width: 200px;">
                            <svg xmlns="http://www.w3.org/2000/svg" width="260" height="66" viewBox="0 0 260 66"><circle fill="#1A171B" cx="32.455" cy="32.665" r="32.455"></circle><path fill="#FFF" d="M46.644 12.219c-3.297.115-6.175 1.932-8.317 4.446-2.372 2.756-3.95 6.025-5.087 9.362-2.034-1.667-3.603-3.825-6.866-4.766-2.522-.724-5.171-.425-7.607 1.39-1.154.862-1.949 2.165-2.327 3.39-.979 3.183 1.029 6.016 1.941 7.033l1.994 2.137c.411.419 1.401 1.512.917 3.079-.523 1.704-2.577 2.807-4.684 2.157-.941-.287-2.293-.988-1.99-1.975.125-.404.414-.706.569-1.055.142-.3.21-.525.253-.657.385-1.257-.141-2.892-1.487-3.307-1.256-.385-2.541-.08-3.039 1.537-.565 1.837.314 5.171 5.023 6.623 5.517 1.695 10.184-1.309 10.846-5.227.417-2.454-.691-4.277-2.721-6.622l-1.654-1.829c-1.002-1.001-1.346-2.707-.309-4.018.875-1.106 2.121-1.578 4.162-1.023 2.979.809 4.307 2.876 6.523 4.543-.915 3.001-1.513 6.013-2.054 8.714l-.33 2.014c-1.584 8.308-2.793 12.87-5.935 15.489-.633.45-1.538 1.124-2.902 1.171-.715.022-.946-.47-.956-.684-.017-.502.406-.732.687-.958.42-.229 1.055-.609 1.012-1.826-.046-1.438-1.237-2.685-2.959-2.628-1.29.044-3.256 1.258-3.182 3.48.077 2.295 2.216 4.015 5.441 3.906 1.724-.059 5.574-.761 9.368-5.271 4.416-5.17 5.651-11.097 6.58-15.435l1.037-5.727c.576.069 1.192.115 1.862.131 5.5.116 8.251-2.733 8.292-4.805.027-1.254-.823-2.488-2.013-2.46-.852.024-1.922.591-2.179 1.769-.251 1.156 1.75 2.199.186 3.212-1.111.719-3.103 1.226-5.908.814l.51-2.819c1.041-5.346 2.325-11.922 7.196-12.082.355-.018 1.654.016 1.684.875.009.287-.062.36-.398 1.017-.342.512-.471.948-.455 1.449.047 1.365 1.085 2.262 2.586 2.208 2.01-.065 2.588-2.022 2.555-3.027-.081-2.361-2.57-3.853-5.865-3.745z"></path><path fill="#1A171B" d="M196.782 23.534c7.48 0 12.499 5.407 12.499 12.887 0 7.048-5.116 12.886-12.499 12.886-7.435 0-12.55-5.838-12.55-12.886 0-7.48 5.018-12.887 12.55-12.887zm0 22.109c5.306 0 7.671-4.827 7.671-9.222 0-4.68-2.847-9.217-7.671-9.217-4.877 0-7.724 4.537-7.724 9.217.001 4.394 2.365 9.222 7.724 9.222zM183.61 25.825v-1.713h-6.518v-2.341c0-3.33.483-5.842 4.391-5.842.072 0 .149.005.224.008.008 0 .007-.012.016-.012 1.085.08 1.987-.804 2.048-1.887l.08-1.486c-.915-.146-1.884-.29-3.039-.29-6.709 0-8.255 3.91-8.255 9.896v1.955h-5.795v1.913c.149.99.996 1.752 2.031 1.752.006 0 .009.005.016.005h3.748V48.73h2.5l.006-.001c1.04 0 1.892-.779 2.03-1.779V27.783h4.538a2.052 2.052 0 0 0 1.979-1.958zm-60.435-1.713c-.008 0-.013.006-.024.006-.956 0-1.882.657-2.286 1.545l-6.244 18.82h-.096l-6.106-18.81c-.399-.893-1.329-1.555-2.291-1.555-.011 0-.015-.006-.024-.006h-3.164l8.351 22.977c.291.821.871 2.077.871 2.606 0 .483-1.353 6.08-5.409 6.08-.1 0-.201-.009-.3-.017-1.034-.057-1.815.665-1.989 1.779l-.124 1.57c.82.145 1.645.338 3.092.338 5.984 0 7.769-5.455 9.46-10.185l9.073-25.149h-2.79zm-28.843 5c-3.747-1.917-7.847-3.218-7.918-7.076.012-4.097 3.776-5.172 6.677-5.169.012-.002.024-.002.031-.002 1.26 0 2.268.125 3.251.34.013 0 .011-.016.027-.016 1.039.076 1.911-.737 2.034-1.762l.083-1.488c-1.902-.473-3.889-.712-5.619-.712-6.309.039-10.992 3.213-11.007 9.268.009 5.296 3.578 7.349 7.416 9.207 3.764 1.81 7.888 3.305 7.924 7.674-.023 4.56-4.423 6.241-7.455 6.247-1.773-.006-3.698-.449-5.32-.96-1.017-.168-1.851.729-1.982 1.917l-.138 1.327c2.23.72 4.517 1.348 6.815 1.348h.027c7.065-.051 12.557-2.869 12.578-10.185-.011-5.645-3.604-8.016-7.424-9.958zm68.623 19.617l.006-.001c.98 0 1.796-.687 2.004-1.604V32.947c0-5.358-2.267-9.413-8.546-9.413-2.219 0-5.934 1.257-7.623 4.779-1.306-3.331-4.15-4.779-7-4.779-3.619 0-6.082 1.303-7.816 4.152h-.099v-1.532a2.058 2.058 0 0 0-2.055-2.036c-.008 0-.014-.006-.022-.006h-2.169v24.617h2.456l.006-.001a2.06 2.06 0 0 0 2.059-2.059c0-.03.011-.042.016-.063v-10.28c0-4.585 1.834-9.122 6.467-9.122 3.669 0 4.396 3.811 4.396 6.853V48.73h2.49l.007-.001a2.05 2.05 0 0 0 2.037-1.873v-10.53c0-4.585 1.835-9.122 6.468-9.122 3.667 0 4.393 3.811 4.393 6.853V48.73h2.525zm70.113 0l.008-.001a2.054 2.054 0 0 0 2.049-1.964v-12.66c0-6.611-2.85-10.571-9.222-10.571-3.426 0-6.705 1.691-8.059 4.491h-.097v-1.839c0-.001-.004-.001-.004-.006a2.057 2.057 0 0 0-2.058-2.061c-.011 0-.015-.006-.022-.006h-2.311v24.617h2.493l.007-.001a2.05 2.05 0 0 0 2.038-1.895v-9.495c0-5.984 2.319-10.135 7.482-10.135 3.96.24 5.211 3.038 5.211 8.783v12.742h2.485zm24.428-24.617c-.011 0-.014.006-.026.006-.954 0-1.883.657-2.283 1.545l-6.242 18.82h-.102l-6.104-18.81c-.401-.893-1.331-1.555-2.293-1.555-.007 0-.015-.006-.021-.006h-3.164l8.351 22.977c.291.821.873 2.077.873 2.606 0 .483-1.355 6.08-5.41 6.08-.102 0-.201-.009-.301-.017-1.033-.057-1.815.665-1.99 1.779l-.122 1.57c.82.145 1.645.338 3.091.338 5.984 0 7.772-5.455 9.462-10.185l9.074-25.149h-2.793z"></path></svg>
                        </a>
                        <!-- end of Symfony link and logo -->
                    </div>
                </div>
            </div>
        </div>
    </nav>

    <header class="bg-white">
        <div class="max-w-7xl mx-auto py-4 px-4 sm:px-6 lg:px-8">
            {% block dh_auditor_header %}{% endblock %}
        </div>
    </header>
    <main>
        <div class="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
            {% block dh_auditor_content %}{% endblock %}
        </div>
    </main>
</div>
{% block javascripts %}{% endblock %}
</body>
</html>

Thank you so much. I had tried what you suggested, but I used DHAuditor instead DHAuditorBundle! Makes sense why I had no joy.