[eluser]ytsejam[/eluser]
Hello ,
I am a novice coder and trying to learn about CI. Now mysite works in the homepage. Site opens , navigation and content splits into both sites. I can use ajax. I use MY_Controller.php :
Code:
function render_page($view) {
if( ! $this->input->is_ajax_request() )
{
$this->load->view('templates/header', $this->data);
}
$this->load->view($view, $this->data);
if( ! $this->input->is_ajax_request() )
{
$this->load->view('templates/menu');
$this->load->view('templates/footer', $this->data);
}
}
my home controller :
Code:
public function view($page = 'home')
{
$this->load->helper('text');
$this->data['records']= $this->services_model->getAll();
if ( ! file_exists('application/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->render_page('pages/'.$page,$data);
}
works and I can get the services-table from the database. and I can use it in the view file as :
Code:
<ul class="blog-medium">
<?php foreach($records as $row): ?>
<li>
<div class="blog-medium-text">
<h1><a href="./post.html"><?php echo $row->title; ?></a></h1>
<p class="blog-medium-excerpt"><?php echo $row->content; ?><br />
<a href="./post.html" class="read_more">Devamını Okumak için →</a></p>
</div>
<?php endforeach ?>
But when i click about page I cant get the about table . It gives me undefined variable infos.
about controller :
Code:
public function view($page = 'about')
{
$this->load->model('about_model');
$this->load->helper('text');
$data['infos']= $this->about_model->getAll();
if ( ! file_exists('application/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->render_page('pages/'.$page,$data);
}
and my about view :
Code:
<?php foreach($infos as $row): ?>
<h3>
<?php echo $row->title; ?></h3>
<!-- ELEGANT HORIZONTAL LINE -->
<div class="hr"> </div>
<!-- NUMBERED LIST -->
<?php echo $row->content; ?>
<?php endforeach; ?>
thank you .