Welcome Guest, Not a member yet? Register   Sign In
CI newbie question regarding tutorial
#1

[eluser]Adam_R[/eluser]
I'm new to CodeIgniter so I have decided to follow user guide first and actually I'm stuck on http://ellislab.com/codeigniter/user-gui...ction.html :\

I'm able to display "news" but when I click to see particular news by slug I'm getting 404 error. Links to slug part looks like /index.php/news/news/test-X and routes are:

Code:
$route['news/create'] = 'news/create';
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

All code is copy-paste from the user guide tutorial.

No clue why news is doubled.

Thanks
#2

[eluser]Matias Perrone[/eluser]
This forum is for bugs, check the "Code!" forum
#3

[eluser]Adam_R[/eluser]
Can admin/moderator move that topic there? Thanks
#4

[eluser]Aken[/eluser]
It has to do with the links that are created on the news homepage - there's an extra "news" segment in the URL. Search around, it has been brought up countless times.
#5

[eluser]Adam_R[/eluser]
Thanks for a tip! I found and resolved issues. IMO tutorial code from the User Guide should be fixed to avoid any issues like mine.
#6

[eluser]Narf[/eluser]
There's nothing wrong with the tutorial.
#7

[eluser]Adam_R[/eluser]
That part was wrong and actually somebody fixed it:

Code:
public function view($slug)
{
$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');
}

there was

Code:
$data['news'] = $this->news_model->get_news($slug);
#8

[eluser]Narf[/eluser]
This argument is pointless, but your claim is simply not true. Smile

The last time that page was modified is Oct 8th, 2012 (you can even verify that by looking at the HTTP response headers when you load the page). And even that is just a mark for CodeIgniter's latest release and not when this particular page was actually updated.
#9

[eluser]Aken[/eluser]
The $data array key was wrong at one point, it has been resolved. The relative URL in the index view continues to confuse new users.




Theme © iAndrew 2016 - Forum software by © MyBB