PHP Classes

File: examples/cms/app/blog/controllers/posts.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   PHP Skeleton Framework   examples/cms/app/blog/controllers/posts.php   Download  
File: examples/cms/app/blog/controllers/posts.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 8 years ago
Size: 1,139 bytes
 

Contents

Class file image Download
<?php

class posts extends A_Controller_Action {

    function
__construct($locator) {
       
parent::__construct($locator);
    }
   
   
/* Default action: show list of latest */
   
function index($locator) {
       
$action = $this->request->get('action');
       
       
// If there's a request for a single post
       
if( $this->request->has('action') && is_numeric($this->request->get('action')) ){
           
           
// How to translate URL in correct action variable?
           
$model = $this->_load()->model('postsModel');
           
$content = $model->single();
           
$template = $this->_load()->template('singlePost');
           
$template->set('content', $content);
# $maincontent = $template->render();
           
           
$this->response->set('maincontent', $template);
           
$this->response->set('subcontent','This is the subcontent');

        }
        else
// show all posts
       
{
           
$model = $this->_load()->model('postsModel');
           
$content = $model->listAll();
           
$template = $this->_load()->template();
           
$template->set('content', $content);
           
$maincontent = $template->render();

           
$this->response->set('maincontent', $maincontent);
           
$this->response->set('subcontent','This is the subcontent');

        }
               
    }

}