CI controller calls internal methods and loads corresponding templates. ci Controller
When I open the link: http: // localhost/3g/index/open/a/B? After from = timeline, determine whether the from in the link is equal to timeline. If it is equal to timeline, call the timeline method in the Controller and load the timeline. php template.
class Index extends CI_Controller { function __construct() { parent::__construct(); } public function open($a=0,$b=0) { if ($_GET['from'] == 'timeline') { $this -> timeline($a); die; } else { $data['b'] = $b; $this -> load -> view('3g/index/open',$data); } } public function timeline($a=0) { $data['a'] = $a; $this -> load -> view('3g/index/timeline',$data); }}
The output page is blank and the timeline. php template is not loaded. The correct method is:
class Index extends CI_Controller { function __construct() { parent::__construct(); } public function open($a=0,$b=0) { if ($_GET['from'] == 'timeline') { $this -> timeline($a); die; } else { $data['b'] = $b; $this -> load -> view('3g/index/open',$data); } } public function timeline($a=0) { $data['a'] = $a; echo $this -> load -> view('3g/index/timeline',$data,true);die; }}
Get View content
View function thirdOptionalParameters can change the function behavior, so that data is returned as a string instead of sent to the browser. This is useful if you want to use other methods to further process data. If the third parameter of view is set to true (Boolean), the function returns data. The default action of the view function is false, which sends data to the browser. If you want to return data, remember to assign it to a variable:
$string = $this->load->view('myfile', '', true);
Example: in some cases, you don't want to output the view directly, but just want to get the View content for future use. You can refer to the following code.
<? Phpclass Blog extends CI_Controller {function index () {$ data ['todo _ list'] = array ('clean house', 'Call Ms', 'Run errands '); $ data ['title'] = "My Real title"; $ data ['heading'] = "My Real heading "; $ buffer = $ this-> load-> view ('blogview', $ data, true) ;}}?>
The third parameter in the view method indicates that the view is not output, but the result is returned to a variable.
Php ci framework development. The content is not displayed when the template is called.
Right-click the source code to see if it is blank or what?
<? Php?> Go
Template reinforcement practices, pay attention to how it is done, not those solutions such as beam side template take Steel
Are you still in trouble? Simple and clear