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   329 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, 5513 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.