<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Example extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function _remap($method, $params = array())
{
// dynamically assign the method with parameters support
$this->view($method, $params);
}
public function product_modules($domain_id)
{
$this->load->model('/admin/Model_products', '', TRUE);
$data['product_boxes'] = $this->Model_products->getProducBoxes($domain_id);
$this->load->view('admin/dashboard', $data, null, true);
}
public function view($method, $param1 = '', $param2 = '')
{
// params you can sent to models
$data['users'] = $this->model_name->get_user($param1);
// or views
$data['myvar'] = $param2;
// and load the view dynamically
$this->load->view($method, $data);
}
}
所以
如果 URL 是http://example/controller/method
那么上面将搜索method.php
视图文件,
如果 URL 是http://example/controller/product_modules/1
则它搜索product_modules.php
视图文件。
希望这可以帮助。谢谢!!