Modifying a Helper |
[eluser]NateL[/eluser]
So does CodeIgniter know when I've created my own helper in the Application/helpers folder - and treat that as default? For example... the default url_helper.php in system/helpers (CI's core) has the url_title() function. I want to modify that and create my own. So would I create url_helper.php inside application/helpers - and then create a new function called url_title - then modify it to what I need? It looks like - based on this line of code in the core url_helper.php - that is the case: Code: if ( ! function_exists('url_title')){...} But I just want to be sure
[eluser]GSV Sleeper Service[/eluser]
you're on the right track, see the section labelled "extending" helpers for full details. http://ellislab.com/codeigniter/user-gui...lpers.html
[eluser]NateL[/eluser]
Yah I broke my app tinkin around with it all..and then read up on that article.. I have it named MY_url_helper.php I'm trying to strip the spaces out instead of giving it a dash or underscore. (lowercase == true) So if I put in "XYZ Corp" - that function will convert it to "xyzcorp" so I just added this bit of code between the default if/else statement: Code: function url_title($str, $separator = 'dash', $lowercase = FALSE)
[eluser]wowdezign[/eluser]
The inflector helper has a humanize() function that strips out the spaces. Could you do something like: Code: $stringToAlter = "Here_Is_My_string";
[eluser]NateL[/eluser]
It looks like it replaces underscores with spaces... Code: $word = "my_dog_spot"; I need to remove the spaces to it returns MyDogSpot (and then I'll use the strtolower function to make it mydogspot)
[eluser]NateL[/eluser]
Code: $clientdir = url_title($this->input->post('clientname'), 'underscore', TRUE); This returns the desired effect. Not sure if there is a better way.
[eluser]wowdezign[/eluser]
Sorry, I posted the wrong function. I meant the camelize() function. The camelize() function strips out the spaces. You could combine it with the strtolower() PHP function to get the results you want. |
Welcome Guest, Not a member yet? Register Sign In |