Building a Blog with Codeigniter tutorial question [Solved!] |
[eluser]Mantra of Doom[/eluser]
Hello everyone, I've been following a tutorial called Building a Blog with Codeigniter on eeinsider.com, which is a pretty good tutorial for me with the exception that it promises a fourth part that was never posted. I noticed that in the link to the post with the full post, it uses the following code to make the link: Code: a href="/blog/entry/<?php echo $entry->url_title; ?>"><?php echo $entry->title; ?></a> It seems that this method only really works if there is an .htaccess file to take out the "index.php" from the url. This seems to work okay, but I wonder if there isn't a better way. I'm just wondering if this might be the reason I'm having issues adding pagination to a blog built with this tutorial. Any hints or a poke in the right direction would be helpful. I love codeigniter so far and the user guide and community are full of helpful things. Thanks in advance for any advice. I'm posting the code for those that have not seen this tutorial yet. The Model Code: //Gets all entries in the blog table Code: <h2>Blog</h2>
[eluser]bretticus[/eluser]
Check out the anchor function of the URL Helper. Also, for more up-to-date tutorials, check out the nettuts CodeIgniter from Scratch video series.
[eluser]Cesar Kohl[/eluser]
I would do something like this: First, enable URL Helper: Code: $this->load->helper('url'); Second, use anchor function to create a link: Code: anchor('blog/entry'.$entry->url_title,$entry_title)
[eluser]Mantra of Doom[/eluser]
Thanks bretticus and Cesar Kohl, the URL helper is what I was looking for. The only thing with this method Code: anchor('blog/entry'.$entry->url_title,$entry_title) is that I get this error: Quote:A PHP Error was encountered Line 12 is where my anchor tag is. Where is it that I define $entry_title since $entry comes from the query loop in the view?
[eluser]LuckyFella73[/eluser]
Try: Code: anchor('blog/entry'.$entry->url_title,$entry->title) instead of: Code: anchor('blog/entry'.$entry->url_title,$entry_title)
[eluser]Mantra of Doom[/eluser]
I feel really stupid now, thanks LuckyFella73! I thought I had tried that and it didn't work. I guess I must have missed something simple. Thanks for all the help guys, I'm going to mark this as solved.
[eluser]LuckyFella73[/eluser]
Naaah don't feel stupid - making such kind of mistakes will never end. They just become rare more and more |
Welcome Guest, Not a member yet? Register Sign In |