• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wildcard Url

Hi i am trying to add more parameters to my rewrittten urls, suppose i have.

book-name is the slug.

What do i need to do to add an extra segment to the url also keeping the slug i.e.

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.

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
$route['books/(:any)/(:any)'] = "books/bookName/$1/$2";
Than make this controller application/controllers/books.php
<?php if (!defined('BASEPATH')) die();
class Books extends CI_Controller

   public function __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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.