0

I would like to have a single controller generate multiple views depending on user input (in this case HTTP links) something like this:

public function video_home($ref_link)
{ 
     if ('user clicked link here'){

         $data = 'some stuff';

         $this->load->view('view1', $data)
        }
     elseif('2nd user clicked link here){
         $data = 'some stuff';

         $this->load->view('view2', $data)
        }

     $this->load->view('page with links here')
 }

I'm having a tough time trying to determine a way to get the ref link to pass to the conditionals. Any ideas?

1 Answer 1

2

The $ref_link in your function would be a url parameter. So it would be accessed like this

www.example.com/video_home/link-one

public function video_home($ref_link){ 
     if ($ref_link == 'link-one'){

         $data = 'some stuff';

         $this->load->view('view1', $data);
     }
     else if($ref_link == 'link-two'){
         $data = 'some stuff';

         $this->load->view('view2', $data);
     }
     else{
         $this->load->view('page-links');
     }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.