Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Tutorial help
#1

[eluser]Unknown[/eluser]
Hello

I've just completed the codeigniter tutorial found here http://ellislab.com/codeigniter/user-gui...pages.html, with the two differnet views, pages and news. I was wondering if anyone could help me link the two together.

Do I need to add to the controllers?

thankyou

pages controller

Code:
<?php

class Pages extends CI_Controller {

public function view($page = 'home')
{
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->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
         $this->load->library('image_lib');
         $this->load->helper('url');

}


}
news controller
Code:
<?php
class News extends CI_Controller {

public function __construct()
{
  parent::__construct();
  $this->load->model('news_model');
}

public function index()
{
  $data['news'] = $this->news_model->get_news();
          $data['title'] = 'News archive';

          $this->load->view('templates/header', $data);
          $this->load->view('news/index', $data);
          $this->load->view('templates/footer');
}

public function view($slug)
{
if ( ! file_exists('application/views/news/'.$news.'.php'))

  $data['news_item'] = $this->news_model->get_news($slug);

if (empty($data['news_item']))
{
  show_404();
}

$data['title'] = $data['news_item']['title'];

$this->load->view('templates/header', $data);
$this->load->view('news/view', $data);
$this->load->view('templates/footer');
}

         public function create()
         {
$this->load->helper('form');
$this->load->library('form_validation');

$data['title'] = 'Create a news item';

$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('text', 'text', 'required');

if ($this->form_validation->run() === FALSE)
{
  $this->load->view('templates/header', $data);
  $this->load->view('news/create');
  $this->load->view('templates/footer');
  
}
else
{
  $this->news_model->set_news();
  $this->load->view('news/success');
}
       }



}
#2

[eluser]Unknown[/eluser]
sorry for the vague post, how would I link the page home.php (views/pages/home.php) to the index.php (views/news/index.php)and vice versa? as well as the other news pages?




Theme © iAndrew 2016 - Forum software by © MyBB