h_h
h_h

Reputation: 1231

Extending codeigniter helper methods

I have been developing a project in codeigniter, and I need to change the functionality of a function called site_url() of url_helper. I have already extended the url_helper in my application/helper folder by naming it MY_url_helper, and I can load/access it. What I want to know is, How can I extend the functionality of site_url() function. Do I need to create another method with different name called site_url_ext() in my extended helper, or is there a way to extend the current function.

Thanks.

Upvotes: 0

Views: 210

Answers (1)

Morgs
Morgs

Reputation: 1746

I think first you need to understand what "Extending" basically means. By extending a helper class, you get exposed to the functionality the helper class is offering, which means that you don't have to re-write it. You cannot extend (as in inherit) a function / method. If you would like to add more functionality to the already existing site_url() function, you can create your own separate function and name it as you wish e.g. site_url_ext(), copy the code in the original site_url() if need be and start modifying from there on-wards. Alternatively code your own site_url_ext() altogether. If it's just the base_url you would like to modify then do only that in the constructor of the url_helper class.

Upvotes: 1

Related Questions