ktm
ktm

Reputation: 6085

How to access function from every controller in codeigniter

Hi friends hi have this function in one controller , how can i access it from every other controller ?pls help

public function click_add($ads_id){
    //some statement here
    redirect($ads_site['url']);
}

Upvotes: 2

Views: 771

Answers (2)

thomaux
thomaux

Reputation: 19738

There are a few possibilities:

  • Define a helper
  • Create a parent controller class from which all other controllers in your application extend
  • Create a library
  • Use ModularExtensions to allow calling one controller inside another

It all depends on what exactly the function should do. If it shouldn't access the model, then you could go for the first three options. Otherwise I'd suggest the latter two.

Upvotes: 3

Bruce
Bruce

Reputation: 1542

One solution would be to create your own library.

Upvotes: 3

Related Questions