Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » UrlSegment Question

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

Page: 1
Go to End
Author Topic: 230 Views
  • Dave0808
    Avatar
    Community Member
    2 Posts

    UrlSegment Question Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: UrlSegment Question Link to this post

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

  • Dave0808
    Avatar
    Community Member
    2 Posts

    Re: UrlSegment Question Link to this post

    Thanks Willr. That is pretty much what I thought.

    230 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.