2
\$\begingroup\$

I'm calling a view into a view. Am I doing correctly, or is this a bad practice?

<div class="tab-pane" id="tab_1_2">
 <div class="portlet ">
 <div class="portlet-title">
 <div class="caption">
 <i class="icon-reorder"></i> Nuevo Usuario
 </div>
 </div>
 <?php $this->load->view('modules/user/form_add_user'); ?>
 </div>
</div>
syb0rg
21.9k10 gold badges113 silver badges192 bronze badges
asked Jan 30, 2014 at 15:17
\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

For your controller, a method like this would be best to call all your variables:

$data = array(
 "add_user" => $this->load->view('form_add_user'),
 "username" => $username,
 "admin" => $admin
);

(Variables are made up just for example)

Then, within your code, do this:

<div class="tab-pane" id="tab_1_2">
 <div class="portlet ">
 <div class="portlet-title">
 <div class="caption">
 <i class="icon-reorder"></i> Nuevo Usuario
 </div>
 </div>
 <?=$add_user;?> <!-- looks cleaner -->
 </div>
</div>
answered Jan 30, 2014 at 15:54
\$\endgroup\$
2
  • \$\begingroup\$ form_add_user is a large html form and I placed in another view for that reason. \$\endgroup\$ Commented Jan 30, 2014 at 16:07
  • \$\begingroup\$ Completely re-wrote answer after some research + your comment @AndreFontaine \$\endgroup\$ Commented Jan 30, 2014 at 16:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.