Search code examples
phpsymfonysonata-adminsymfony-sonatasonata-user-bundle

Symfony2 - SonataUserBundle - user profile dashboard


How I can get user profile section to looks like this below?

enter image description here

https://github.com/sonata-project/SonataUserBundle/blob/master/Resources/doc/reference/user_dashboard.rst

My current profile pages looks ugly.. Do I need to rewrite all that *.html files or Sonata has implemented this layouts like in SonataAdminBundle and I need to change some configuration?

I'm using: SonataUserBundle with FOSUserBundle, SonataAdminBundle

enter image description here enter image description here

As @lxer said, there is some problem with css/twig extending layouts because file sonata-project\user-bundle\Resources\biews\Profile\action.html.twig renders like this:

                    <div class="row-fluid clearfix">

    </div>

<h2>Dashboard</h2>

<div class="sonata-user-show row row-fluid">

    <div class="span2 col-lg-2" style="padding: 8px 0;">
                    <div id="cms-block-555ed9f4923a2" class="cms-block cms-block-element">
                    <div class="list-group">
                                                <a href="/sf2/product/web/app_dev.php/profile/" class="list-group-item active ">Dashboard</a>                    

                                    <a href="/sf2/product/web/app_dev.php/profile/edit-profile" class="list-group-item">Profile</a>                    

                                    <a href="/sf2/product/web/app_dev.php/profile/edit-authentication" class="list-group-item ">Authentication</a>                    


        </div>

</div>

            </div>

    <div class="span10 col-lg-10">

            <div class='alert alert-default alert-info'>
    <strong>This is the user profile template. Feel free to override it.</strong>
    <div>This file can be found in <code>SonataUserBundle:Profile:show.html.twig</code>.</div>
</div>
    <div class="row row-fluid">

        <div class="span6 col-lg-6">
                                                <div id="cms-block-555ed9f493295" class="cms-block cms-block-element">
        <h2>Welcome!</h2> This is a sample user profile dashboard, feel free to override it in the configuration! Want to make this text dynamic? For instance display the user's name? Create a dedicated block and edit the configuration!
</div>

                                    </div>


        <div class="span6 col-lg-6">
                                                </div>
    </div>
    </div>

</div>

So there's missing some part of code... Why it not extending anything? Here's original file

{#

This file is part of the Sonata package.

(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{% block sonata_page_breadcrumb %}
    {% if breadcrumb_context is not defined %}
        {% set breadcrumb_context = 'user_index' %}
    {% endif %}
    <div class="row-fluid clearfix">
        {{ sonata_block_render_event('breadcrumb', { 'context': breadcrumb_context, 'current_uri': app.request.requestUri }) }}
    </div>
{% endblock %}

<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>

Solution

  • I have the same issue. I followed the instructions for installation, while no one says how to connect the built-in styles. The fact that it takes MopaBootstrapBundle. When you set up, you should have noticed the error that it is not installed. Use the generated ApplicationSonataUserBundle for adding a stylesheets. This is important information for beginners. I was confused when I saw the look of personal account. You must copy the templates from

    vendor/sonata-project/user-bundle/Resources/views
    

    and paste it in

    src/Application/Sonata/UserBundle/Resources/views
    

    Then you can explore it. I must say that they have issues in the logic. For example, duplication of header on change_password page, when it embedded in auth page.

    Use bootstrap CDN for fast install

    {%block stylesheets%}
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
    
        <!-- Optional theme -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
    
        <!-- Latest compiled and minified JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    {%endblock%}
    

    Paste it in your

    src/Application/Sonata/UserBundle/Resources/views/layout.html.twig 
    src/Application/Sonata/UserBundle/Resources/views/Profile/action.html.twig
    

    Hope it helps! Sorry for Google translate, edits are welcome.