Welcome Guest, Not a member yet? Register   Sign In
Error in User Guide
#1

[eluser]Unknown[/eluser]
Hi everyone,

I've been learning how to use codeigniter, and I think it's great!

I'm not sure where to post this, and I just wanted to post a quick error that I think I might have found in the user guide:
http://ellislab.com/codeigniter/user-gui...ction.html

Under the "display the news", the code for application/views/news/index.php the code it says is:
Code:
<?php foreach ($news as $news_item): ?>

    <h2>&lt;?php echo $news_item['title'] ?&gt;</h2>
    <div id="main">
        &lt;?php echo $news_item['text'] ?&gt;
    </div>
    <p><a href="news/&lt;?php echo $news_item['slug'] ?&gt;">View article</a></p>

&lt;?php endforeach ?&gt;
However, I think it should be: (The change is in the link)
Code:
&lt;?php foreach ($news as $news_item): ?&gt;

    <h2>&lt;?php echo $news_item['title'] ?&gt;</h2>
    <div id="main">
        &lt;?php echo $news_item['text'] ?&gt;
    </div>
    <p><a href="view/&lt;?php echo $news_item['slug'] ?&gt;">View article</a></p>

&lt;?php endforeach ?&gt;
When the code in the guide is used, you get this weird recursive sort of url happening over and over again...

Please let me know if I've posted in the wrong place or I'm speaking nonsense.
Best,
DG Kim

#2

[eluser]Eduard Stankovic[/eluser]
Yes, there is mistake, but your solution doesn't fix that.

your solution just link to method not to controller

it should be like that :
Code:
site_url("news/view/".$news_item['slug']);


sorry for my english Smile
#3

[eluser]Unknown[/eluser]
Hi, thanks for the response.

I tried my solution and it worked just fine, it just added the method and the slug after the news. I think this is because I didn't add a / in front of the view in the link tags.
#4

[eluser]Aken[/eluser]
It's because the user guide suggests using a relative URL. It may cause "problems" for new users, but it's a very common issue with making websites and it should be understood how it works. It's also the best option to keep the tutorial as simple and universal as possible. A slash at the start of the link wouldn't work if someone had CodeIgniter installed in a subdirectory. Using site_url() is a good option, but then you have to introduce helpers and everything in the tutorial also.




Theme © iAndrew 2016 - Forum software by © MyBB