Skip to content

Instantly share code, notes, and snippets.

@overwine
Created August 2, 2012 18:28
Show Gist options
  • Save overwine/3239431 to your computer and use it in GitHub Desktop.
Save overwine/3239431 to your computer and use it in GitHub Desktop.
master controller and m_master(model)
<?php
class M_Master extends CI_Model
{
public function findURI( $uri )
{
$query = $this->db->where( 'uri', $uri )->limit(1)->get('pages');
if ( $query->num_rows > 0 )
{
echo '<pre>';
print_r($query->row());
echo '</pre>';
return $query->row();
}
return false;
}
}
?>
<?php if( !defined('BASEPATH')) exit('No direct script access allowed');
class Master extends CI_Controller
{
function __construct()
{
parent::__construct();
}
public function _remap( $method )
{
// remap overrides function calls
$this->load->library('single_column'); //put this in here because I don't know what I'm doing
// search for uri in db
$this->load->model('m_master');
$uri_id = $this->m_master->findURI( uri_string() );
if ( $uri_id != false )
{
// uri exists! load template controller
$this->{$uri_id->controller}->render( $uri_id->id ); //possibly incorrect placment
}
else
{
show_404( uri_string() );
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment