Tuesday, 15 January 2013

CodeIgniter Tutorial glitches

As part of general web development, I make a point of checking out the state of the numerous PHP frameworks that are available to the community. Today I had been working through the CodeIgniter tutorial and noticed a couple of glitches (which I found solutions for). In particular, these both relate to the News parts of the tutorial.

In 'application/views/news/index.php', I had to remove the 'news/' in the href attribute:
<?php foreach ($news as $news_item): ?>
 <h2><?php echo $news_item['title'] ?></h2>
 <div id="main">
  <?php echo $news_item['text'] ?>
 <p><a href="<?php echo $news_item['slug'] ?>">View article</a></p>

<?php endforeach ?>
In 'application/controllers/news.php', I added the following method:
public function success()
 $data['title'] = 'Success';

 $this->load->view('templates/header', $data);
 $this->load->view('news/success', $data);
And lastly, In 'application/config/routes.php', I added this:
$route['news/success'] = 'news/success';

No comments:

Post a Comment