使用 Bootstrap 自定义 FOSUserBundle 登录模板 [英] Custom FOSUserBundle Login Template using Bootstrap
问题描述
我已经安装了 Symfony2、FOS User Bundle 和 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.
这篇关于使用 Bootstrap 自定义 FOSUserBundle 登录模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!