Welcome Guest, Not a member yet? Register   Sign In
Simple question/issue...new to CodeIgniter
#11

[eluser]Aken[/eluser]
Base URL needs to be the full URL path, including http://. Without that, it's just acting like a relative URL, which is why it's being repeated.
#12

[eluser]codelogic[/eluser]
[quote author="Aken" date="1337984670"]Base URL needs to be the full URL path, including http://. Without that, it's just acting like a relative URL, which is why it's being repeated.[/quote]

Aken I found my issue before I saw your post but yes this did work! I guess the fix was minor.


But... i'm running into another issue now where I want to view a single article, however it redirects me to index.php/news/news/(my article) instead of index.php/news/(my article).

index.php creates the "view article" link.


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;
#13

[eluser]Aken[/eluser]
Again, it's a relative URL issue.
#14

[eluser]codelogic[/eluser]
[quote author="Aken" date="1337985171"]Again, it's a relative URL issue.[/quote]

I removed news/ from this line
Code:
<p><a href="news/&lt;?php echo $news_item['slug'] ?&gt;">View article</a></p>

However, I still get a "Page not found" error when I try to view index.php/news/(article)
#15

[eluser]Aken[/eluser]
Could be a route issue, or incorrect slug, or still a relative problem. I can't really say for sure. Your app is not complicated, though, so just keep poking around until you figure it out. Look at the URLs and see if anything is different, check your routes, verify that it isn't the show_404() function creating the error page, etc.
#16

[eluser]codelogic[/eluser]
[quote author="Aken" date="1337985899"]Could be a route issue, or incorrect slug, or still a relative problem. I can't really say for sure. Your app is not complicated, though, so just keep poking around until you figure it out. Look at the URLs and see if anything is different, check your routes, verify that it isn't the show_404() function creating the error page, etc.[/quote]

Found the issue... there was something wrong with the view($slug) code in my news.php controller, I may have been missing a bracket or something. Whatever it was, my app works now.

Thanks for the help/advice everyone!
#17

[eluser]PhilTem[/eluser]
Try using the url-helper and its anchor() function. Then you won't ever have problems with false relative url (as long as your base-url is set correctly).

Or you set a base tag in your template, then you can enter anchors directly into your view without the helper.




Theme © iAndrew 2016 - Forum software by © MyBB