[eluser]kpspoke[/eluser]
I have two controllers, welcome.php and header.php
both work on their own while browsing just to them individually. But when i try and include the header controller using wick i get this error: Call to a member function query() on a non-object. welcome has no database calls. the database() and auth() library are loaded automatically.
thanks in advance.
Code:
welcome.php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->wick->light('header/index');
$this->load->view('welcome_message');
}
}
header.php
class Header extends Controller{
function Header(){
parent::Controller();
$this->load->model('navigation');
}
function index(){
$nav = new Navigation;
echo $nav->buildNav();
}
}
navigation.php
class Navigation extends Model{
function Navigation(){
parent::Model();
}
function buildNav($userGroup = FALSE){
$security = ($userGroup) ? $userGroup : 1;
//query for parents
$parents = $this->db->query("SELECT * FROM navigation WHERE ((navGroup<=$security) AND (isParent=1));");
$results = "";
$results .= "<ul id='nav'>";
foreach($parents->result() as $parent){
$results .= "<li>";
$results .= "<a >" . $parent->navTitle . "</a>";
//gets children of parentID
$children = $this->db->query("SELECT * FROM navigation WHERE ((navParent=$parent->navID) AND (navGroup<=$security));");
if(!empty($children)){
$results .= "<ul>";
foreach($children->result() as $child){
$results .= "<li><a >navLink . "'>" . $child->navTitle . "</a></li>";
}
$results .= "</ul>";
}
$results .= "</li>";
}
$results .= "</ul>";
return $results;
}
}