Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

UrlSegment Question

Go to End

3 Posts   669 Views


Community Member, 2 Posts

28 May 2013 at 8:58pm

Edited: 28/05/2013 9:22pm

Hi guys,

Is it possible to use a wildcard when evaluating a UrlSegment?

I have a form application and once a submission occurs the user always ends up on a page the ends with .../finished (e.g. I'd like to add some specific content that only shows up on the /finished pages.

I'm looking for something such as this to add to my

<% if URLSegment = */finished* %>
Do something
<% else %>
Do something else
<% end_if %>

Any thoughts are much appreciated.


Forum Moderator, 5523 Posts

28 May 2013 at 10:24pm

Nope, can't do wildcard searches so you'd have to write custom function on your 'Page' class to perform the operation.

For example

function MatchesFinish() {
return preg_match('/\/finished/', $this->Link());

<% if MatchesFinish %>
<% end_if %>


Community Member, 2 Posts

28 May 2013 at 10:58pm

Thanks Willr. That is pretty much what I thought.