Created
November 30, 2009 15:31
-
-
Save walesmd/245496 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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