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.

General Questions

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

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

UrlSegment Question


Reply

3 Posts   254 Views

Avatar
Dave0808

28 May 2013 at 8:58pm (Last edited: 28 May 2013 9:22pm), Community Member, 2 Posts

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

28 May 2013 at 10:24pm Forum Moderator, 5511 Posts

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

28 May 2013 at 10:58pm Community Member, 2 Posts

Thanks Willr. That is pretty much what I thought.