使用Bootstrap自定义FOSUserBundle登录模板

问题描述:

我已经安装了Symfony2,FOS用户捆绑包和Twitter Bootstrap.

I've installed Symfony2, FOS User Bundle and Twitter Bootstrap.

然后,我设置/app/Resources/FOSUserBundle/views/layout.html.twig模板以覆盖FOSUserBundle以使用我的网站模板.

Then I setup the /app/Resources/FOSUserBundle/views/layout.html.twig template to override FOSUserBundle to use my site template.

如果我在首页上有指向/login的链接,那么一切正常.

It all works if I have a link to /login on the homepage.

现在,我想实现一个类似于英雄模板的模板,在其中登录表单是主模板的一部分.

Now I want to implement a template like the hero template where the login form is part of the main template.

最接近的是在主模板中使用它:

The closest I've got is to use this in the main template:

{% render controller("FOSUserBundle:Security:login") %}

我可以覆盖布局html以不扩展主模板,但这会删除/login中的所有样式

I can override the layout html to not extend main template, but this removes all styling from /login

有什么想法我可以同时处理这两种情况吗?

Any ideas how I can handle both scenarios?

理查德·米勒(Richard Miller)的帖子帮助我实现了我想要做的事情.

Richard Miller's post has helped me achieve what I was trying to do.

http://richardmiller.co .uk/2013/02/18/symfony2-ajax-and-full-page-templates/

{% extends app.request.attributes.get('partial')
     ? '::ajax-layout.html.twig'
     : '::full-layout.html.twig' %}

我无法使app.request.partial工作,并决定基于xmlRequest的选择并不理想.

I couldn't get app.request.partial to work, and decided choosing based on xmlRequest wasn't ideal.