I need to make a dynamic page that is something like : example.com/nameofbook/1
- where 1 is the number of the page.
This are 2 parameters.
I know 2 ways of doing it. 1. In controller I have function page($book, $page) 2. Take from the link the parameters with this->uri->segment.
What should I use and why and which one is safer?
Anyhow when I use the controller with 2 parameters the CSS code doesn't load. When I use 1 it loads. my route is something like $route['page/(:any)/(:any)']='main/page/$1/$2'
.
Thanks in advance.
using the $this->uri->segment is exactly the same as using parameters in the controller.. the parameters will get passed to the controller if its part of the URI whether you have defined them in the method or not.
i.e:
page() {
// This will be an array of passed arguments
$args = func_get_args();
}
I am not sure why your CSS doesn't load with one method over another. also judging by your URI, your route won't work.. because the 'page' part is not in the URI, so your URI should be example.com/page/nameofbook/1
either way is 'safe' it makes no difference in the 2 ways you suggest.