Created
August 2, 2012 18:28
-
-
Save overwine/3239431 to your computer and use it in GitHub Desktop.
master controller and m_master(model)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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