Welcome Guest, Not a member yet? Register   Sign In
Help extending url helper
#1

[eluser]dizzyagain[/eluser]
Greetings,

I am wishing to extend 1 particular function (uri_string) in the URL HELPER.

Have very limited experience in extending something from the core so hoping for some guidance.

Essentially I would like to extend the function to accept a parameter which should provide a MAXIMUM number of segments to return.

i.e:

Code:
echo uri_string(3);

This would ensure a maximum of 3 segments get returned.

Suppose these examples:

demo.com/admin returns admin

demo.com/admin/pages/add/1/2/3 returns admin/pages/add

Finally if no parameter is given the function would behave as it currently does in the core.

i.e:

Code:
function uri_string($max=NULL)
{
// code
}

Can anyone help?

My only thinking so far is I should be doing a php explode and then return a string that has been reconstructed somehow with the maximum number of segments (or all segments if $max == NULL).

Kind Regards,
Ilai
#2

[eluser]pedsa[/eluser]
Only need to add a file MY_url_helper in application/helpers folder, then you can extend or add new functions. When you load url helper, CI will load this extension automatically

See more here: http://ellislab.com/codeigniter/user-gui...lpers.html in "Extending" Helpers




Theme © iAndrew 2016 - Forum software by © MyBB