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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   930 Views

Avatar
Dave0808

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. xxx.example.com/ss/myform/finished0001). 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 Page.ss:

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

Any thoughts are much appreciated.

Avatar
Willr

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 %>

Avatar
Dave0808

Community Member, 2 Posts

28 May 2013 at 10:58pm

Thanks Willr. That is pretty much what I thought.