如何在codeigniter中将一些值从一个视图传递到另一个视图?

I have an application done on Code-igniter.

I wanted to pass title and URL to another page when I click on a link to the next page.

For e.g.
Page one - properties/home/details/titleofthecontent - in this page i have a link report it .

When i click on report it i will get next page /report_abuse .Here I need to get the page title and the URL from the previous page.

I have the variable to pass but how could I pass it? This is same as passing values from one view to another view.

Inside your controller, have

$data['nestedView']['otherData'] = 'testing';

before your view includes.

When you call

$this->load->view('view_destinations',$data);

the view_destinations file is going to have

$nestedView['otherData'];

Which you can at that point, pass into the nested view file.

From what you explain, I understand that you want to pass some data from a controller to another (since your URL's are different).

To do this, you can:

  1. Pass the data through query strings (GET) as explained above or
  2. Set a flash data variable in the first controller, and use it in the second. I would advise to use this solution, as that's why flash data exists.

You can use $this->uri->segment() of Codeigniter like below.

$this->uri->segment(1); // controller
$this->uri->segment(2); // action
$this->uri->segment(3); // 1stsegment
$this->uri->segment(4); // 2ndsegment

You can pass the variables values via url and get on the controller. and so on.