ライブラリー内にこの関数((click_add))を入れて、すべてのコントローラーから呼び出せるようにしようとしています。私はすでにライブラリにget_ads()関数を持っています。私はclick_add(id)関数をライブラリに移してget_adsとともに表示するよう呼び出すが、うまくいきません。コントローラー関数をcodeigniterのライブラリーに移動する
function __construct() {
parent::__construct();
$this->load->library('ads');
$this->load->model('MGlobal');
}
public function index(){
$data['banner']= $this->ads->get_ads();
$this->load->view('test',$data);
}
//i want this in library but no luck
public function click_add($ads_id){
$ads_site = $this->MGlobal->getAds($ads_id);
$this->MGlobal->add_ads_view();
redirect($ads_site['url']);
}
//とビューは、この
foreach($banner as $k=>$list){
echo anchor('test/click_add/'.$list['bannerid'],'<img src="'. $list['image']. '"/>');
}
のようなものです助けてくださいそれは、MVCの各部分の役割を覚えておくことも重要ですどのように私は、ライブラリ
ライブラリの機能にルーティングすることはできません。 – mahadeb
可能な複製:http://stackoverflow.com/questions/7553912/how-to-access-function-from-every-controller-in-codeigniter/7554110#7554110 – thomaux