wdphd
wdphd

Reputation: 915

Suggestions for website template/design - Backend

I'm creating a website using Codeigniter which hosts online novels/e-books. The novel(s) have multiple chapters similar to a hard copy. Im planning to design the layout as following.

User goes to chapter 1, so the URL would be site.com/novel/chapter1/pageno

I plan to create a novel controller which has chapter1,2.. etc as its functions. The chapter function receives an input and gets the same form either a database or from a text file. I'd also want to store user progress which can be resumed later. I plan to use the chapter/pageno as the reference for where the user currently has stopped.

I'd like to know if this approach is good and is it possible to limit the functions and make it more generic. Alternative approach to this concept would also be helpful.

Upvotes: 0

Views: 200

Answers (1)

umefarooq
umefarooq

Reputation: 4574

yes you can make it more generic it routes you have to add route in routes.php under config directory like this

$route['novel/(chapter-[0-9]+)/(:any)'] = 'novel/chapter/$1/$2';

now url will be www.site.com/novel/chaper-20/60

novel controller

class Novel extends CI_Controller{


  function chapter($chaper_no,$page_no){

     echo $chpter_no,'  ',$page_no;
  }
 // if you don't want to pass variables to chapter function use the following

  function chapter(){
        $chapter_no = $this->uri->segment(2);
        $page_no = $this->uri->segment(3);
  }

}

if you are registering users in you site create a bookmark link ask him to save the page, if you are not registering users on your site you can set cookie to save user progress by just clicking same bookmark link or make it on each page load

Upvotes: 1

Related Questions