Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

17480 Posts in 4474 Topics by 1973 members

Archive

SilverStripe Forums » Archive » Unigue URL Segment in SiteTree::write()

Our old forums are still available as a read-only archive.

Page: 1
Go to End
Author Topic: Unigue URL Segment in SiteTree::write() 1019 Views
  • xmedeko
    avatar
    Community Member
    94 posts

    Unigue URL Segment in SiteTree::write() Link to this post

    Hi,
    I made a page "My 2nd Page" and my URLSegment was "my-2nd-page", then I have duplicated this page, and my URL segment has been changed to "mynd-page-2" (wrong). I made the patch:

    --- SiteTree.php.orig   2007-08-06 17:48:37.000000000 +1200
    +++ SiteTree.php   2007-08-06 17:47:06.000000000 +1200
    @@ -419,7 +419,7 @@
          $count = 1;
          while(DataObject::get_one("SiteTree", "URLSegment = '$this->URLSegment' $idFilter")) {
             $count++;
    -         $this->URLSegment = ereg_replace('-[0-9]+','', $this->URLSegment) . "-$count";
    +         $this->URLSegment = ereg_replace('-[0-9]+$','', $this->URLSegment) . "-$count";
          }
          
          // If the URLSegment has been changed, rewrite links

    And then duplication made URLSegment "my-2nd-page-2" (is that better?)

  • Sean
    avatar
    Core Development Team
    482 posts

    Re: Unigue URL Segment in SiteTree::write() Link to this post

    That sounds good to me. I guess it was a miss that it did what it was originally doing, with a number already in the URL segment. Andy, could you make sure this is patched in the main branch?

    Sean

  • Andy
    avatar
    229 posts

    Re: Unigue URL Segment in SiteTree::write() Link to this post

    Thanks, I applied this!

    1019 Views
Page: 1
Go to Top

Currently Online: ss_freebie, walec51

Welcome to our latest member: marcusl

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

Comments on this website? Please give feedback.