Symfony2 - SonataUserBundle - 用户配置文件仪表板

时间:2015-05-22 07:10:08

标签: php symfony sonata-admin symfony-sonata sonata-user-bundle

我如何才能将用户个人资料部分看起来如下所示?

enter image description here

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

我目前的个人资料页面看起来很难看...... 我是否需要重写所有* .html文件或者Sonata已经像SonataAdminBundle那样实现了这种布局,我需要更改一些配置吗?

我正在使用: 带有FOSUserBundle的SonataUserBundle,SonataAdminBundle

enter image description here enter image description here

正如@lxer所说,css / twig扩展布局存在一些问题,因为文件sonata-project\user-bundle\Resources\biews\Profile\action.html.twig呈现如下:

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

因此,缺少部分代码......为什么不扩展任何内容? 这是原始文件

{#

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>

2 个答案:

答案 0 :(得分:1)

我有同样的问题。我按照说明进行安装,但没有人说如何连接内置样式。需要MopaBootstrapBundle的事实。设置时,您应该已经注意到它未安装的错误。使用生成的ApplicationSonataUserBundle添加样式表。这对初学者来说是重要的信息。当我看到个人账户的样子时,我很困惑。您必须从

复制模板
vendor/sonata-project/user-bundle/Resources/views

并将其粘贴到

src/Application/Sonata/UserBundle/Resources/views

然后你可以探索它。我必须说他们在逻辑上有问题。例如,当它嵌入在auth页面中时,在change_password页面上重复标题。

使用bootstrap CDN进行快速安装

{%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%}

将其粘贴到您的

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

希望它有所帮助!对不起Google翻译,欢迎编辑。

答案 1 :(得分:0)

您忘了包含CSS文件, 或者他们404出于某种原因(可能是错误的路径)。