IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Doctrine2 PHP Discussion :

Problème d'affichage après QueryBuilder


Sujet :

Doctrine2 PHP

  1. #1
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2012
    Messages
    35
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2012
    Messages : 35
    Par défaut Problème d'affichage après QueryBuilder
    Bonsoir !

    Bon décidemment j'ai pas mal de problème avec mes queryBuilder et autre. Je m'explique :

    Dans mon forum sur ma page nommée forum.html.twig j'aimerai afficher mes topics rangé dans un ordre croissant en fonction de la date de son dernier post.

    J'ai donc dans mon controller :

    ForumController :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    public function forumAction(Forum $forum, $tagForum)
    	{
    		$category = $forum->getCategorie();
    		// $topics = $forum->getTopics();
     
    		$listeTopics = $this->getDoctrine()
    					   ->getEntityManager()
    					   ->getRepository('SdsForumBundle:Forum')
    					   ->findByIdOrderByPostsDateASC($forum->getId());
     
    		return $this->render('SdsForumBundle:Forum:forum.html.twig', array('forum' => $forum, 'tagForum' => $tagForum, 'category' => $category, 'listeTopics' => $listeTopics));
    	}
    Mon ForumRepository :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
    public function findByIdOrderByPostsDateASC($id)
    	{
    		$qb = $this->createQueryBuilder('f')
    		->join('f.topics', 't')
    		->addSelect('t')
    		->join('t.posts', 'p')
    		->addSelect('p')
    		->where('f.id = :id')
    		->setParameter('id', $id)
    		->orderBy('p.date', 'ASC');
     
    		return $qb->getQuery()
    			      ->getResult();
    	}
    ma page forum.html.twig :

    {# src/Sds/ForumBundle/Resources/views/Forum/forum.html.twig #}

    {% extends "SdsSiteBundle::layout.html.twig" %}

    {% block title %}Forum - {{ parent() }}{% endblock %}

    {% block sdssite_body %}

    <div id="forum">

    <div id="globalforum">
    <div id="catforums">

    <p>
    <a style="color: #bc2a4d;" href="{{ path('SdsForumBundle_accueil') }}">
    {{ category.nom|upper }}
    </a><span style="font-size: 8px; font-weight: bold;"> << </span>
    <a style="color: #bc2a4d;" href="{{ path('SdsForumBundle_forum', { 'id': forum.id, 'tagForum': tagForum }) }}">
    {{ tagForum|upper }}
    </a>
    </p>
    <table class="categories">
    <thead>
    <tr>
    <th style="width: 100px;">SUJETS</th>
    <th style="width: 100px;">REPONSES</th>
    <th style="width: 100px;">VU</th>
    <th style="text-align: center; width: 240px;">DERNIER MESSAGE</th>
    </tr>
    </thead>

    {% if listeTopics is defined %}

    {% if listeTopics is empty %}

    <tbody class="forums">
    <tr>
    <td>
    Aucun topic n'est disponible dans ce forum
    </td>
    </tr>
    </tbody>

    {% endif %}

    {% for topic in listeTopics %}

    <tbody class="forums">
    <tr>
    <td style="padding-left: 5px;">
    <a href="{{ path('SdsForumBundle_topic', { 'id': topic.id, 'tagTopic': topic.titre }) }}">{{ topic.titre }}</a><br />
    </td>
    <td style="text-align: center;">
    <span style="font-size: 10px; font-weight: bold">{{ topic.post }}</span>
    </td>
    <td style="text-align: center;">
    <span style="font-size: 10px; font-weight: bold">{{ topic.vu }}</span>
    </td>
    <td style="text-align: center;">

    {% include "SdsForumBundle:Forum:lastPost.html.twig" with { 'post' : topic.lastPost } %}

    </td>
    </tr>
    </tbody>

    {% endfor %}

    {% endif %}

    </table>

    </div>
    </div>

    </div>

    {% endblock %}
    Bien sur ça ne fonctionne pas et je passe des heures sans trouver ma réponse.

    Merci d'avance.

  2. #2
    Membre éclairé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2012
    Messages
    394
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2012
    Messages : 394
    Par défaut
    ça te met quoi comme erreur et c'est quoi ta route elle a combien de paramètres !

Discussions similaires

  1. problème d'affichage après execution d'une macro
    Par ptitemar dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 07/08/2007, 17h45
  2. Problème d'affichage après import Excel
    Par e040098k dans le forum IHM
    Réponses: 1
    Dernier message: 25/06/2007, 12h20
  3. Réponses: 2
    Dernier message: 18/07/2006, 09h29
  4. Problème d'affichage après un tri....
    Par lyim dans le forum Langage
    Réponses: 4
    Dernier message: 27/04/2006, 17h06
  5. [Menu] Problème d'affichage après redirection
    Par Pfeffer dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 22/03/2006, 21h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo