【问题标题】:Symfony2 - SonataUserBundle - user profile dashboardSymfony2 - SonataUserBundle - 用户资料仪表板
【发布时间】:2015-05-22 07:10:07
【问题描述】:

如何让用户个人资料部分如下所示?

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

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

我正在使用: SonataUserBundle 与 FOSUserBundle、SonataAdminBundle

正如@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>

【问题讨论】:

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


    【解决方案1】:

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

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

    并粘贴到

    src/Application/Sonata/UserBundle/Resources/views
    

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

    使用引导 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
    

    希望对您有所帮助!抱歉谷歌翻译,欢迎修改。

    【讨论】:

    • 您好,感谢您的回复。我已经添加了那些 CSS,所以现在页面看起来更好,但仍然缺少部分代码(例如&lt;html&gt;&lt;head&gt;...&lt;/head&gt;&lt;body&gt;..)它们呢?我需要从我的布局中自己添加它吗?
    • 你可以为所欲为。是的,在您的模板中添加遗漏的部分。随意覆盖它!
    • 好的,恕我直言,这是非常重要的信息... Sonata 应该将此信息添加到他们的文档中...我花了 2 天时间来弄清楚...谢谢
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2016-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-11
      • 2011-12-29
      • 2011-04-20
      • 2017-07-15
      • 1970-01-01
      相关资源
      最近更新 更多