Welcome Guest, Not a member yet? Register   Sign In
Slug problem
#5

[eluser]srpurdy[/eluser]
[quote author="msy07" date="1344481343"]Thank you for the replies!

[quote author="PhilTem" date="1344443785"]Please show us your view and how you're creating the links! This way it's easier for us to help you![/quote]

This is the view for showing up all the news.

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> //this is the line that produces the link to view the specific post

&lt;?php endforeach ?&gt;

[quote author="CroNiX" date="1344446041"]Why add the trailing slash anyway? It doesn’t provide any benefit unless something comes after.[/quote]

I was just trying to figure out why it behaves that way. Smile[/quote]

Actually has Nothing to do with codeigniter. That's how paths work.

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

to This
Code:
<a href="&lt;?php echo base_url();?&gt;news/&lt;?php echo $news_item['slug'];?&gt;">View article</a>

It's always good practice to use base_url or site_url because this saves a lot of problems.


Messages In This Thread
Slug problem - by El Forum - 08-08-2012, 08:04 AM
Slug problem - by El Forum - 08-08-2012, 09:36 AM
Slug problem - by El Forum - 08-08-2012, 10:14 AM
Slug problem - by El Forum - 08-08-2012, 08:02 PM
Slug problem - by El Forum - 08-08-2012, 10:00 PM
Slug problem - by El Forum - 08-08-2012, 10:07 PM
Slug problem - by El Forum - 08-08-2012, 10:25 PM
Slug problem - by El Forum - 08-08-2012, 11:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB