Definiremos la plantilla base para nuestras vistas en el fichero app/Resources/views/plantilla.html.twig
En el definiremos algunos bloques, montaremos una navbar con Bootstrap, y el formulario de login.
1 | <!DOCTYPE HTML> |
2 | < html lang = "es" > |
3 | < head > |
4 | < meta charset = "utf8" /> |
5 | < title >{% block title %} Blog en Symfony2 - victorroblesweb.es{% endblock %}</ title > |
6 | <!-- jQuery CDN --> |
7 | < script src = "//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" ></ script > |
8 | <!-- Bootstrap CDN --> |
9 | < link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" > |
10 | < link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css" > |
11 | < script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js" ></ script > |
12 | </ head > |
13 |
14 | < body > |
15 | < header > |
16 | < nav class = "navbar navbar-default" > |
17 | < div class = "container-fluid" > |
18 | <!-- Brand and toggle get grouped for better mobile display --> |
19 | < div class = "navbar-header" > |
20 | < button type = "button" class = "navbar-toggle collapsed" data-toggle = "collapse" data-target = "#bs-example-navbar-collapse-1" > |
21 | < span class = "sr-only" >Toggle navigation</ span > |
22 | < span class = "icon-bar" ></ span > |
23 | < span class = "icon-bar" ></ span > |
24 | < span class = "icon-bar" ></ span > |
25 | </ button > |
26 | < a class = "navbar-brand" href = "{{path(" home")}}">Blog con Symfony2</ a > |
27 | </ div > |
28 |
29 | <!-- Collect the nav links, forms, and other content for toggling --> |
30 | < div class = "collapse navbar-collapse" id = "bs-example-navbar-collapse-1" > |
31 | < ul class = "nav navbar-nav" > |
32 | {%block categorias%} |
33 | < li class = "active" >< a href = "#" >Link < span class = "sr-only" >(current)</ span ></ a ></ li > |
34 | < li >< a href = "#" >Link</ a ></ li > |
35 | {%endblock%} |
36 | </ ul > |
37 | |
38 | < ul class = "nav navbar-nav navbar-right" > |
39 | {% if is_granted('ROLE_USUARIO') or is_granted('ROLE_ADMIN') %} |
40 | < li class = "dropdown" > |
41 | < a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" role = "button" aria-expanded = "false" > |
42 | {{app.user.name}} {{app.user.surname}} |
43 | < span class = "caret" ></ span ></ a > |
44 | < ul class = "dropdown-menu" role = "menu" > |
45 | < li >< a href = "{{path(" new_post")}}">Nuevo post</ a ></ li > |
46 | < li class = "divider" ></ li > |
47 | < li >< a href = "{{path(" logout")}}">Cerrar sesión</ a ></ li > |
48 | </ ul > |
49 | </ li > |
50 | {%endif%} |
51 | </ ul > |
52 | </ div > <!-- /.navbar-collapse --> |
53 | </ div > <!-- /.container-fluid --> |
54 | </ nav > |
55 | </ header > |
56 |
57 | < section class = "content col-lg-9 col-md-9 col-sm-9 col-xs-9" > |
58 | {%block content %} Contenido vacio por defecto {%endblock%} |
59 | </ section > |
60 | < sidebar class = "sidebar col-lg-3 col-md-3 col-sm-3 col-xs-3" > |
61 | {%block identificate %} |
62 | {% if is_granted('ROLE_USUARIO') or is_granted('ROLE_ADMIN') %} |
63 | {#{dump(app.user)}#} |
64 | {% else %} |
65 | < h3 >Identificate</ h3 > |
66 | < hr /> |
67 | {% for mensaje in app.session.flashbag().get('login') %} |
68 | < p class = "info" >{{ mensaje }}</ p > |
69 | {% endfor %} |
70 | {% if error is defined %} |
71 | No estas identificado |
72 | {{error.message}} |
73 | {% endif %} |
74 | < form method = "post" action = "{{path('login_check')}}" > |
75 | < label >Email</ label > |
76 | < input type = "email" name = "_username" value = "" class = "form-control" /> |
77 | |
78 | < br /> |
79 | < label >Contraseña</ label > |
80 | < input type = "password" name = "_password" class = "form-control" /> |
81 | |
82 | < br /> |
83 | < input type = "submit" value = "Entrar" class = "btn btn-success" /> |
84 | < a href = "{{path(" registro")}}" class = "btn btn-warning" >Registrate aquí</ a > |
85 | </ form > |
86 | {% endif %} |
87 |
88 | {%endblock%} |
89 | </ sidebar > |
90 | < div class = "clearfix" ></ div > |
91 | < footer > |
92 | < hr /> |
93 | © victorroblesweb.es |
94 | </ footer > |
95 | </ body > |
96 | </ html > |
97 |
98 | |