Skip to content

Instantly share code, notes, and snippets.

@walesmd
Created November 30, 2009 15:31
Show Gist options
  • Save walesmd/245496 to your computer and use it in GitHub Desktop.
Save walesmd/245496 to your computer and use it in GitHub Desktop.
<?php if (!defined('BASEPATH')) exit('No direct script access allowed.');
class Articles extends Controller {
function Articles() {
parent::Controller();
}
function edit($id = NULL) {
if ($id !== NULL) {
// Load this article's data
// If the article doesn't exist, redirect to the creation form
$this->load->model('article');
$data['article'] = $this->article->get($id);
if ($article === FALSE) redirect('articles/create');
}
$data['partial'] = 'articles/edit';
$this->load->view('layout', $data);
}
// You could also accomplish this by using the config/routes.php file
function create() {
$this->edit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment