2

I've got a variable like {current_url} which contains the full url of the page you are on.

I want to strip out the last segment from it.

Is there a plugin or native EE way of doing that?

Say that variable is example.com/me/you and i want to remove the "you" from the end, how would i do that?

Due to variable url segments, i can't do {segment_2}{segment_3}{segment_4} as "you" might be the second or third or fourth variable.

Thanks

4 Answers 4

7

Low's stuff is allways awesome. I was thinking of this, pretty awesome too. http://www.causingeffect.com/software/expressionengine/ce-string?

1
  • CE String is awesome and indispensable. It's like a Swiss Army Knife.
    – adrienne
    Nov 25, 2012 at 23:14
6

Found it, the brilliant @low strikes again with a great plugin called Low Replace!

Syntax like:

{exp:low_replace find="you" replace=""}{current_url}{/exp:low_replace}

Cool!

2
  • exactly what i was going to suggest.
    – CreateSean
    Nov 22, 2012 at 17:04
  • I'm trying to do exactly that right now - AWESOME!
    – JKM
    Nov 27, 2012 at 1:49
4

You could also try PHPStringFun and the str_replace function. PHPStringFun lets you run php functions on the template without enabling PHP.

It'll be overly complex for this but is useful if you need to do anything more than just replace text (or use any other phpfunctions).

2

Surgeree also does regex replace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.