Remove 'segments' from url |
[eluser]Jakob Pedersen[/eluser]
Hi! :-) First of all this looks like a fantastic community and I simply love how simple and straightforward CodeIgniter actually is (I'm coming from a heavily moded Joomla site, which was turning into a nightmare) In the last couple of days I've worked intensely with creating my own CMS with a backend interface, but I have to issues/hurdles I want to overcome: 1) I would love if my content urls (with articles) were much simpler. Right now they follow this pattern: domain.com/content/comments/this-is-a-blog-title Content is obviously the controller and comments a function in the controller, but I would love if I could remove these to segments from the url when calling excactly that controller to this: domain.com/this-is-a-blog-title - especially because that's the way it's on my current Joomla site. But on every other controller the URL has to be normal and follow the usual pattern: domain.com/controller/function 2) Right know the only way to link to an article is to do it with the comment view, but that doesn't include the article -any easy way to combine them, so you don't have to go to different pages? Thank you very much, and sorry if you have answered this before - I really have searched for a solution.
[eluser]pistolPete[/eluser]
Have a look at URI Routing: - http://ellislab.com/codeigniter/user-gui...uting.html - http://ellislab.com/forums/viewthread/107394/
[eluser]Jakob Pedersen[/eluser]
[quote author="pistolPete" date="1267456755"]Have a look at URI Routing: - http://ellislab.com/codeigniter/user-gui...uting.html - http://ellislab.com/forums/viewthread/107394/[/quote] Thanks, but I've tried that several times and can't get it working probably. If I put this in the routing config: Code: $route[':any'] = 'content/comments/:any'; Furthermore the other controllers don't work any longer (probably sort of a given, since it routes everything to content/comments) but I've got no clue on how to only enable the routing for the content controller including the third uri segment..
[eluser]pistolPete[/eluser]
You have to use the correct syntax as described in the user guide: Code: $route['(:any)'] = 'content/comments/$1'; Quote:Furthermore the other controllers don’t work any longer...Read this: http://ellislab.com/forums/viewreply/540633/
[eluser]stef25[/eluser]
CI's routing feature is excellent, allows you to use pretty much any URL you want. I'm using it in a large app and adding one line to the routing file for every "section" of your site is really not that much work.
[eluser]Jakob Pedersen[/eluser]
[quote author="stef25" date="1267467275"]CI's routing feature is excellent, allows you to use pretty much any URL you want. I'm using it in a large app and adding one line to the routing file for every "section" of your site is really not that much work.[/quote] Yeah that would be perfectly fine, but this code: Code: $route['(:any)'] = 'content/comments/$1'; still redirects only to the function, not the specific article (defined with a slug table)
[eluser]pistolPete[/eluser]
Can you post the content controller? You could also use this route: Code: $route[':any'] = 'content/comments/'; and get the segment using Code: $this->uri->segment(1)
[eluser]Jakob Pedersen[/eluser]
I changed the anchor to use the segment-1 - so the article work now, but I'm not able to comment: content.php [controller] Code: <?php content.php [view] Code: <div id="container"> comment_view.php [view] Code: <div id="container"> Structure: views: ..content.php ..comment_view |
Welcome Guest, Not a member yet? Register Sign In |