![]() |
url_title() HELP - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: url_title() HELP (/showthread.php?tid=37847) |
url_title() HELP - El Forum - 01-22-2011 [eluser]HSKrustofsky[/eluser] I know this has been posted a bunch of times, but still can't seem to get the grasp of it. No matter what I do, it doesn't seem to work properly. I am trying to convert: index.php/blog/5 To: index.php/blog/this_is_my_blog I saw that the best way to achieve this is with using url_title(). Well, this is how I am trying to us it, and it doesn't work: Code: <?= anchor('idnex.php/blog/' . $row->id . url_title($row->title, 'underscore', true), '' . $row->title); ?> The link works but it adds the title after the ID number(which I kind of figured would happen). Anything else I try just kills the link, or the page. Any suggestions? url_title() HELP - El Forum - 01-22-2011 [eluser]Bas Vermeulen[/eluser] You still have $row->id in your link, try: Code: <?= anchor('index.php/blog/' . url_title($row->title, 'underscore', true).'', $row->title); ?> url_title() HELP - El Forum - 01-22-2011 [eluser]HSKrustofsky[/eluser] Tried that, but it doesnt really link to anything. With no ID, it doesn't know where to go... url_title() HELP - El Forum - 01-22-2011 [eluser]Bas Vermeulen[/eluser] Hmm weird, this example works for me. Echo of $row->title shows the title? url_title() HELP - El Forum - 01-22-2011 [eluser]HSKrustofsky[/eluser] It shows the title, but it links to the title and not the ID. So when you click the link, it's got nothing to reference to, but the title. url_title() HELP - El Forum - 01-22-2011 [eluser]fraserk[/eluser] How about this. Code: $title = $row->title; Then Code: <?= anchor('idnex.php/blog/' . $row->id .$url_title, . $row->title); ?> url_title() HELP - El Forum - 01-22-2011 [eluser]cideveloper[/eluser] your problem is that your index function in the blog controller is expecting an id not the title. If you use what Bas said Code: <?= anchor('index.php/blog/' . url_title($row->title, 'underscore', true).'', $row->title); ?> you should get a link that looks like this Code: <a href="http://localhost/index.php/blog/blog_article_title">blog_article_title</a> your blog function should look something like this Code: function index($title=''){ Please show us your index function in the blog controller. url_title() HELP - El Forum - 01-22-2011 [eluser]Bas Vermeulen[/eluser] Ah yes cideveloper is right, I just thought your <a> function didn't work ;p |