Foros del Web » Programando para Internet » PHP » Symfony »

[SOLUCIONADO] Variable no muestra su valor en Twig

Estas en el tema de Variable no muestra su valor en Twig en el foro de Symfony en Foros del Web. Este es mi controlador: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código PHP: Ver original public function listado_oficialesAction ( ) {         $em = $this -> getDoctrine ...
  #1 (permalink)  
Antiguo 28/05/2013, 20:00
 
Fecha de Ingreso: mayo-2013
Mensajes: 17
Antigüedad: 11 años
Puntos: 0
Pregunta Variable no muestra su valor en Twig

Este es mi controlador:

Código PHP:
Ver original
  1. public function listado_oficialesAction() {
  2.         $em = $this->getDoctrine()->getEntityManager();
  3.         $oficiales = $em->getRepository('InvestigacionesPolicialesBundle:Oficial')->findAll();
  4.         return $this->render("InvestigacionesPolicialesBundle:Oficial:listado_oficiales.html.twig", array('oficiales' => $oficiales));
  5.     }

Y en mi vista tengo esto:

Código HTML:
Ver original
  1. <table class="listado" border="1">
  2.     <thead>
  3.         <tr>
  4.             <th>ID</th>
  5.             <th>CI</th>
  6.             <th>Nombre</th>
  7.             <th>Apellidos</th>
  8.         </tr>
  9.     </thead>
  10.     {% for oficial in oficiales %}
  11. <tr>
  12.     <th>{{ oficial.id }}</th>
  13.     <th>{{ oficial.ci }}</th>
  14.     <th>{{ oficial.nombre }}</th>
  15.     <th>{{ oficial.apellidos }}</th>
  16. </tr>
  17.     {% endfor %}

El problema es que no me muestra el ID, sin embargo los demás datos me los muestra sin problemas.
  #2 (permalink)  
Antiguo 28/05/2013, 22:11
Avatar de masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 3 meses
Puntos: 845
Respuesta: Variable no muestra su valor en Twig

No hay mucho misterio, comprueba el accessor de la propiedad porque el path simplemente lo que haces es invocarlo.

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)
  #3 (permalink)  
Antiguo 29/05/2013, 12:34
 
Fecha de Ingreso: mayo-2013
Mensajes: 17
Antigüedad: 11 años
Puntos: 0
Respuesta: Variable no muestra su valor en Twig

No se bien a qué te refieres, si es al getId() en la entidad Oficial sí lo tengo puesto, si puedes explícate un poco más para entender, y gracias por tu tiempo.
  #4 (permalink)  
Antiguo 29/05/2013, 15:32
 
Fecha de Ingreso: mayo-2013
Mensajes: 17
Antigüedad: 11 años
Puntos: 0
Respuesta: Variable no muestra su valor en Twig

Ya, lo que pasaba era que la entidad Oficial hereda de Persona, lo que hice fue definir el getId de esta forma en la clase Oficial:

Código PHP:
public function getId() {
        return 
parent::getId();
    } 
  #5 (permalink)  
Antiguo 14/10/2013, 05:29
 
Fecha de Ingreso: noviembre-2010
Mensajes: 234
Antigüedad: 13 años, 5 meses
Puntos: 2
Respuesta: Variable no muestra su valor en Twig

No lo entiendo, lo tengo igual que tu pero a mi continua tirnadome un error:

Código PHP:
Ver original
  1. $em = $this->getDoctrine()->getEntityManager();
  2.        
  3.         $peliculas = $em->getRepository('VideoBundle:Video')->findAll();
  4.        
  5.         return $this->render('VideoBundle:Front:index.html.twig', array(
  6.             'peliculas' => $peliculas
  7.         ));

Y en Twig:

Código Twig:
Ver original
  1. {% if pelicula is peliculas %}
  2.                                     <article>
  3.                                         <a href="#" class="zoom pescash"><img src="{{ asset('bundles/front/images/caratulas/caratula1.png') }}" alt="thumbnail" /></a>
  4.                                         <h4>{{ pelicula.nombre }}</h4>
  5.                                     </article>
  6.                                                                         {% endif %}

Pero no entiendo lo que comentas en el último Post.

Saludos!

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:30.