Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter - What kind of variable can work during controller is called?
    primarykey
    data
    text
    <p><strong>The first thing I want to ask is how does controller work?</strong> Assuming that I have a controller:</p> <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Home extends CI_Controller { public static $groupId; 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)); self::$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 seft:$groupId; } } /* End of file home.php */ /* Location: ./application/modules/front/controllers/home.php */ </code></pre> <p>When I access <code>http://localhost:8080/ci/</code> and <code>http://localhost:8080/ci/television</code> and then type <code>http://localhost:8080/ci/test/</code>, I get white screen. If in the first time controller is called (use method in controller), and in the second time, I think controller don't need reload so from group method, I set value for $groupId and in the test method I can get it easy but I can't. Maybe when I call test method, controller is reloaded.</p> <p><strong>The second thing I want to ask, how to pass $groupId through other method?</strong> Remember! $groupId doesn't store in controller, I get it from url.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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