I’m not sure how to do this because its not echoing my html. Its showing the div tag in firebug but not anything else after it which should be either the index page(homepage) or my 404 page. What’s supposed to happen is its supposed to find out which page view its supposed to load via the if statement and then load load that view inside the content page.
Controller:
$siteInfo = $this->kow->getSiteTitleAndSlogan();
$activeTemplate = $this->kow->getTemplate();
if ($this->kow->pageStatus('index', $activeTemplate[0]->short_name) == 1){
$page = $this->load->view($activeTemplate[0]->short_name.'/pages/index');
} else {
$page = $this->load->view($activeTemplate[0]->short_name.'/pages/404');
}
$footerLinks = $this->kow->getFooterNav();
$this->template
->title($siteInfo[0]->site_name,$siteInfo[0]->site_slogan)
->prepend_metadata('<link rel="stylesheet" type="text/css" href="http://www.kansasoutlawwrestling.com/assets/css/'.$activeTemplate[0]->short_name.'.css" />')
->set('footerLinks', $footerLinks)
->set('page', $page)
->set_partial('header', $activeTemplate[0]->short_name.'/header')
->set_partial('navigation', $activeTemplate[0]->short_name.'/navigation')
->set_partial('content', $activeTemplate[0]->short_name.'/content')
->set_partial('footer', $activeTemplate[0]->short_name.'/footer')
->build('kow');
if ($this->kow->pageStatus('index', $activeTemplate[0]->short_name) == 1){
$page = $this->load->view($activeTemplate[0]->short_name.'/pages/index');
} else {
$page = $this->load->view($activeTemplate[0]->short_name.'/pages/404');
}
View:
<div id="content">
<?php
echo $page;
?>
</div>
EDIT: What I’m trying to do is take the id of the active template and the string index to the pageStatus function and find out if the status of the page has a value of 1. When I run the print_r function like below I get this:
Array ( [0] => Array ( [status_id] => 1 ) )
Controller
if ($this->kow->pageStatus('index', $activeTemplate[0]->id) == 1){
$page = $this->load->view($activeTemplate[0]->short_name.'/pages/index', '', true);
} else {
$page = $this->load->view($activeTemplate[0]->short_name.'/pages/404', '', true);
}
print_r($this->kow->pageStatus('index', $activeTemplate[0]->id));
EDIT 2: I’m still not getting the right page to view.
You’re loading the views for index and 404 into the
$pagevariable incorrectly. To store the output of a$this->load->view()call you must includetrueas the third parameter.From the CI user guide
Returning views as data
There is a third optional parameter lets you change the behavior of the function so that it returns data as a string rather than sending it to your browser. This can be useful if you want to process the data in some way. If you set the parameter to true (boolean) it will return data. The default behavior is false, which sends it to your browser. Remember to assign it to a variable if you want the data returned:
Also, the last bit of your code, the second definition of
$pagehappens after the call to->set('page', $page)and->build('kow');which therefore won’t change the output.