how to route to a page that is a member of another page - 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: how to route to a page that is a member of another page (/showthread.php?tid=39893) |
how to route to a page that is a member of another page - El Forum - 03-23-2011 [eluser]johnmerlino[/eluser] Hey all, Rails supports collection and member routes. For example, you may have a dashboard which you call homes controller. This homes controller has a collection of posts so you logically want to access the url like this to get the collection of posts: homes/posts But each post can have one or many images, so you access the url like this now to access the filter of images that belong to that post: homes/posts/1/image In order to be able to click the link on home page (homes/index) and be nagivated to homes/posts/1/image page, you create this in your routes in Rails: resources :homes do collection do get 'posts' end end resources :posts do member do get 'image' end end I want to click on a link on my homes page and be able to navigate to create_image page: homes/posts/1/create_image So when I upload the image, I know to which post it belongs to (in this case post 1). I look at the routing section of codeigniter user documentation and it really doesn't address this occurrence. It just says you can use (:num) to refer to any page number and regular expressions. Any idea how to get the effect I want with routes in codeigniter? Thanks for response. how to route to a page that is a member of another page - El Forum - 03-24-2011 [eluser]johnmerlino[/eluser] Actually, it is pretty simple to do: $route['homes/posts/(:num)/new_image'] = "homes/new_image"; That points it to the homes controller and new_image method. |