Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to call your controller like this:</p> <pre><code>http://localhost:8080/ci/home/group/12 </code></pre> <p>where 12 is your groupid and home is the name of your controller. Use a session for storing your $groupId in the group function:</p> <pre><code>$this-&gt;CI-&gt;session-&gt;set_userdata('groupId', $groupId); </code></pre> <p>To load your $groupId in test use this line of code:</p> <pre><code>$groupId = $this-&gt;CI-&gt;session-&gt;userdata('groupId'); </code></pre> <p>Another solution is (as requested) although it is not best practice, to make a static class called group:</p> <pre><code>&lt;?php class Group { public static $groupId = 12; }?&gt; </code></pre> <p>Then your homecontroller will look like this: <pre><code>include_once 'group.php'; class Home extends CI_Controller { public function __construct() { } public function index() { $this-&gt;load-&gt;model('product_model'); $data['new_products'] = $this-&gt;product_model-&gt;get_new_products(); $data['featured_products'] = $this-&gt;product_model-&gt;get_featured_products(); $data['sale_products'] = $this-&gt;product_model-&gt;get_sale_products(); $data['template'] = 'index'; $data['title'] = 'Home'; $this-&gt;load-&gt;view('master', $data); } public function group($groupId) { $this-&gt;load-&gt;model('group_model'); $this-&gt;load-&gt;model('product_model'); $groupId = array_pop(explode('-', $groupId)); Group::$groupId = $groupId; $data['groupName'] = $this-&gt;group_model-&gt;get_group_name($groupId); $data['allGroupWithQuantity'] = $this-&gt;group_model-&gt;get_group_with_quantity(); $data['products'] = $this-&gt;product_model-&gt;get_products_by_group($groupId); $data['template'] = 'group'; $data['title'] = $data['groupName']-&gt;groupName; $this-&gt;load-&gt;view('master', $data); } public function test() { echo Group::$groupId; } } ?&gt; </code></pre> <p>For more information on controllers check this site:</p> <p><a href="http://ellislab.com/codeigniter/user-guide/general/controllers.html" rel="nofollow">http://ellislab.com/codeigniter/user-guide/general/controllers.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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