pass param to the index of a controller |
[eluser]jongliko[/eluser]
Hi, I'm wondering what's the best way to use the index of my controller in some cases. For example I have : www.mywebsite.com/index.php/news/ in the index of my controller I'll list all my news with pagination. Is their a way to do something like that www.mywebsite.com/index.php/news/paramOffset/paramPerPage/ or the only way is : www.mywebsite.com/index.php/news/list/paramOffset/paramPerPage/ If the only way is the second one, is it better to refresh directly the index to www.mywebsite.com/index.php/news/list/ I'm trying to find the best for the user and the indexation's search robots Thanks for your help
[eluser]Jonathon Hill[/eluser]
1) I wouldn't use the paramPerPage segment - store that in your config files. If the user needs to be able to change it, store it in their session. 2) If you want to eliminate the list segment, create an entry in your routes.php config file per the User Guide: Code: $route['news/(:any)'] = "news/list/$1"; 3) I personally find CI's pagination library a pain to use. Try Paging Simplified. With it your URL would look like: www.mywebsite.com/index.php/news/p:1 for page 1, www.mywebsite.com/index.php/news/p:2 for page 2, etc. 4) If you're concerned about SEO it's standard practice to get rid of index.php in your URL.
[eluser]jongliko[/eluser]
Thanks Jonathon for you sugestion about perPage param, it's indeed better to store it in a session. I was not familiar with the $route config, I'll read and learn about it, but it seems exactly what I needed. Paging Simplified seems to be really good, I wasn't so happy with the basic pagination library. Yes I'm concerned about SEO and I'll get ride of index.php Thanks for your perfect and detailed answers Nicolas |
Welcome Guest, Not a member yet? Register Sign In |