Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If your using HMVC, simply call the module from inside the profile view, ie:</p> <pre><code>echo Modules::run('comments/profileComments', $user-&gt;id); </code></pre> <p>Else: You would need to create a new method in the loader class, to load in the controller seperate from routing.</p> <p>If your really after a quick fix until you come up with a better alternative, you could(depending if both controllers live in the same directory) just include the 'comments' controller in your 'profile' controller and try something like this:</p> <p><strong>{Cons: CI Pagination wont work!}</strong></p> <p><strong>application/controllers/profile.php</strong></p> <pre><code>include 'Comments' . EXT; class Profile extends CI_Controller{ public function __construct () { parent::__construct () ; } public function index( $user_id ){ $commentsPartialView = call_user_func_array(array(new Comments(), "getProfileComments"), array($user_id)); return $this-&gt;load-&gt;view($this-&gt;template, array( 'view' =&gt; 'profiles/_index', 'comments' =&gt; $commentsPartialView )); } } </code></pre> <p>-</p> <p><strong>application/controllers/Comments.php</strong></p> <pre><code>class Comments extends CI_Controller{ public function __construct () { parent::__construct () ; } public function getProfileComments( $user_id ){ $user_comments = ''; //pull from DB //set third param to TRUE for partial view, without main template return $this-&gt;load-&gt;view('comments/show', array( 'user_comments' =&gt; $user_comments ), TRUE); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload