Show existing talks on intro page.
authorhiroto
Wed, 04 Sep 2013 13:00:28 +0900
changeset 42 43ebcb1b5f8d
parent 41 3bedd6ae17bf
child 43 a77cb505f5e3
Show existing talks on intro page.
autotweet-php/src/Org/W3/AutotweetBundle/Controller/DefaultController.php
autotweet-php/src/Org/W3/AutotweetBundle/Entity/TalkRepository.php
autotweet-php/src/Org/W3/AutotweetBundle/Resources/views/Default/intro.html.twig
--- a/autotweet-php/src/Org/W3/AutotweetBundle/Controller/DefaultController.php	Wed Sep 04 12:37:30 2013 +0900
+++ b/autotweet-php/src/Org/W3/AutotweetBundle/Controller/DefaultController.php	Wed Sep 04 13:00:28 2013 +0900
@@ -26,7 +26,8 @@
     }
     
     public function introAction(){
-        return $this->render('OrgW3AutotweetBundle:Default:intro.html.twig', array());
+        $talk = $this->getDoctrine()->getRepository('OrgW3AutotweetBundle:Talk')->findOpenTalk();
+        return $this->render('OrgW3AutotweetBundle:Default:intro.html.twig', array('talk' => $talk));
     }
     
     public function noteAction($id){
--- a/autotweet-php/src/Org/W3/AutotweetBundle/Entity/TalkRepository.php	Wed Sep 04 12:37:30 2013 +0900
+++ b/autotweet-php/src/Org/W3/AutotweetBundle/Entity/TalkRepository.php	Wed Sep 04 13:00:28 2013 +0900
@@ -67,4 +67,16 @@
             $em_default->flush();    
             return $post;
     }
+    
+    public function findOpenTalk(){
+        $em_default = $this->getEntityManager('default'); 
+        $qb = $em_default->createQueryBuilder();
+        $q  = $qb->select(array('a'))
+           ->from('OrgW3AutotweetBundle:Talk', 'a')
+           ->where('a.startedAt != ?1')
+           ->getQuery();
+        $q->setParameters(array(1 => null));
+        $talks = $q->getResult();
+         return $talks;
+    }
 }
--- a/autotweet-php/src/Org/W3/AutotweetBundle/Resources/views/Default/intro.html.twig	Wed Sep 04 12:37:30 2013 +0900
+++ b/autotweet-php/src/Org/W3/AutotweetBundle/Resources/views/Default/intro.html.twig	Wed Sep 04 13:00:28 2013 +0900
@@ -54,6 +54,30 @@
 </ul>
 
 
+<h2>Existing Talks</h2>
+{% if talk|length > 0 %}
+<p><table id="paymentTable" style="border: 1px solid #ccc;" cellspacing="0">
+  <thead>
+    <tr>
+      <th>Title</th>
+      <th>Date</th>
+    </tr>
+  </thead>
+  <tbody>
+    {% for data in talk %}
+     <tr>
+      <td>
+        <a href="{{ path('org_w3_autotweet_note', {'id': data.id}) }}">{%if null==data.title %}{{data.name}}{% else %}{{data.title}}{% endif %}</a>
+      </td>
+      <td>{{data.startedAt|date('Y/m/d')}}</td>
+    </tr>
+{% endfor %}
+  </tbody>
+</table></p>
+
+{% else %}
+No talks.
+{% endif %}
         </div>
         <div class="separator"></div>