[eluser]k2zs[/eluser]
Also,
How can I use MY_Controller? I've had it try extending MX_Controller as well as Controller but nothing I put in it is available. Here is my last attempted MY-Controller file:
Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
/* The MX_Controller class is autoloaded as required */
class MY_Controller extends MX_Controller
{
// this method sets vars to be used by the main template, indicating the status of a cart with items in it
public function __construct()
{
parent::__construct();
// load this controllers model
$this->load->model('Home_model');
$this->load->model('Products_model');
// load this controllers helpers
$this->load->helper('text');
// declare global variables activeCategory $templatePath
$glodal_data['pgID'] = '';
$glodal_data['formAction'] = '';
$glodal_data['templateGlobals'] = $this->buildPage();
$glodal_data['mainNav'] = $this->Home_model->getMainNav();
$glodal_data['navBlock'] = array('components/side_mainNav','components/side_prodNav','components/side_linksNav','components/side_loginForm',);
$glodal_data['contentBlock'] = array('components/body_contentView',);
$this->load->vars($glodal_data);
}
// build default page content based on current URI
function buildPage() {
// Test for any segments in the uri and get the associated page
if ($this->uri->total_segments() == 2) {
// we got segments - lets get a page!
$this->db->like('rootURI', $this->uri->segment(1));
$this->db->like('pageURI', $this->uri->segment(2));
} elseif ($this->uri->total_segments() == 1) {
// we got segments - lets get a page!
$this->db->like('rootURI', $this->uri->segment(1));
// If there are none load the default home page from the database
} elseif ($this->uri->total_segments() == 0) {
// set the default page to load
//$this->db->where('pgType', 1);
$this->db->where("pgType =1 AND parentID =0 AND pgNavOrder =1 LIMIT 1");
//$this->db->order_by('pgNavOrder', 'asc');
}
$q = $this->db->get('pages');
// If there are results
if ($q->num_rows() > 0) {
$data = $q->row_array();
} else {
// build empty results set
$data = $this->buildFieldList();
}
$this->load->vars($data);
return;
}
// converts humanized page name to an acceptable URI string
function build_uri($string){
$slug = preg_replace('/[^A-Za-z0-9-]+/', '-', strtolower($string));
return $slug;
}
// get total number of users
function buildFieldList(){
$fields = $this->db->list_fields('pages');
foreach ($fields as $field)
{
$fieldArray = array(
$field => ''
);
}
return $fieldArray;
}
// used for random data queriess
public function getCustom($selectArray,$fromArray,$whereArray,$orderByArray) {
$this->db->select($selectArray);
$this->db->from($fromArray);
$this->db->where($whereArray);
$this->db->order_by($orderByArray, 'asc');
$q = $this->db->get();
// return result set as an associative array
return $q->result_array();
}
// used for custom sql data queriess
public function getCustomSql($sqlStatement) {
$q = $this->db->query($sqlStatement);
// return result set as an associative array
return $q->result_array();
}
function testFunction($string) {
$testRet = $string . $this->uri->total_segments();
return $testRet;
}
}