Ejemplo n.º 1
0
 public function view($args)
 {
     $posttype = array_shift($args);
     if (empty($posttype)) {
         $this->redirect(PACKAGE_URL . 'posts');
     }
     echo '<h1>' . ucfirst($posttype) . '</h1>';
     $model = $this->loadModel('post_model');
     /* @var $model Post_Model */
     $posts = $model->get_posts($posttype);
     if (!empty($posts)) {
         $table = new G2_ImprovedDataTable();
         $table->set_data($posts, 5);
         $fields = $model->get_fields($posttype);
         $table->set_fields($model->get_fields($posttype, true));
         $table->add_function(PACKAGE_URL . "posts/crud/{$posttype}/[id]", 'Edit');
         $table->add_function(PACKAGE_URL . "posts/delete/{$posttype}/[id]", 'Delete');
         echo $table->render();
     } else {
         echo '<p>No Posts Found</p>';
     }
     echo '<a href="' . PACKAGE_URL . "posts/crud/{$posttype}" . '" class="btn btn-default">Add Post</a>';
 }