index layout now fully separated m/v/c
authorDylan Lloyd <dylan@dylansserver.com>
Sat, 24 Mar 2012 19:17:25 +0000 (15:17 -0400)
committerDylan Lloyd <dylan@dylansserver.com>
Sat, 24 Mar 2012 19:17:25 +0000 (15:17 -0400)
model/index.php
view/index.php

index dc8f6b3..f649ecc 100644 (file)
@@ -2,25 +2,32 @@
 
 class index extends model {
 
+  public $exhibits = array();
+  public $projects = array();
+
+  public function __construct() {
+      parent::__construct();
+      $this->fetch_exhibits();
+      $this->fetch_projects();
+  }
+
   public function display() {
       require_once("view/index.php");
   }
 
-  public function display_exhibits() {
-    echo "<div id='exhibit'>";
+  private function fetch_exhibits() {
     $sql = "SELECT text FROM projects ORDER BY rank";
     $result = $this->db->query($sql);
     while ($entry = $result->fetch_object()) {
-      echo $entry->text;
+      $this->exhibits[] = $entry->text;
     }
-    echo "</div>";
   }
 
-  public function list_projects() {
+  private function fetch_projects() {
     $sql = "SELECT title FROM projects ORDER BY rank";
     $result = $this->db->query($sql);
     while ($entry = $result->fetch_object()) {
-      echo "<li><a class='tab' href='$entry->title'>$entry->title</a></li>";
+        $this->projects[] = $entry->title;
     }
   }
 
index fb2ed19..2f9b0c9 100644 (file)
       border="0"></a>
     </div>
     <div id="content">
-      <?php $this->display_exhibits() ?>
+      <div id='exhibit'>
+        <?php
+          foreach ($this->exhibits as $exhibit) {
+            echo $exhibit;
+          }
+        ?>
+      </div>
       <ul id="portfolio">
         <li>
            <h3>my projects:</h3>
         </li>
-        <?php $this->list_projects() ?>
+        <?php
+          foreach ($this->projects as $project => $title) {
+              echo "<li><a class='tab' href='$title'>$title</a></li>";
+          }
+        ?>
         <li>
           <h3>things i've done for others:</h3>
         </li>