Wildcard Url |
[eluser]Unknown[/eluser]
Hi i am trying to add more parameters to my rewrittten urls, suppose i have. Code: example.com/books/book-name What do i need to do to add an extra segment to the url also keeping the slug i.e. Code: example.com/books/book-name/chapter-1 could even be (example.com/book-name/chapter-1) 1 would be another query parameter. Because book-name isnt a view, how do I keep the slug in the url always with different book names and append another query parameter? I am totally new to codeigniter. Any help would be appreciated thanks.
[eluser]Tpojka[/eluser]
Rewritten URLs are minor task here. You have to make controller that would be well coded for wanted achievment. I will just make starting point for you because it is not small task, but I will try to show how would I do that. Add this line to application/config/routes.php Code: $route['books/(:any)/(:any)'] = "books/bookName/$1/$2"; Code: <?php if (!defined('BASEPATH')) die(); Now, navigate to it. You should see uri string (I have echoed it ont that way on purpose) in page content. Now change arguments in url in your open browser (except 'books' segment) and you will see how is content changed. Plan is next: you need to check every argument you are using with query that will check DB for particular book/chapter or any other property you made your DB organization with. Knowing controllers and models is a must so start with user guide. You will need to study this part of user guide too. If you are familiar with (OOP) PHP, this could be a good starting point for solving that task. If you stuck somewhere, ask. Good luck. |
Welcome Guest, Not a member yet? Register Sign In |