Welcome Guest, Not a member yet? Register   Sign In
Wildcard Url
#2

[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";
Than make this controller application/controllers/books.php
Code:
<?php if (!defined('BASEPATH')) die();
class Books extends CI_Controller

{
   public function __construct()
   {
      parent::__construct();
   }

   public function bookName($name = 'some-name', $chapter = 'some-cahpter1')
   {
      echo strtolower($this->uri->segment(1)) . '/' . $this->uri->segment(2) . '/' . $this->uri->segment(3);
   }

}

/* End of file Books.php */
/* Location: ./application/controllers/Books.php */

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.


Messages In This Thread
Wildcard Url - by El Forum - 11-08-2013, 01:02 PM
Wildcard Url - by El Forum - 11-08-2013, 03:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB