Skip to content

Commit

Permalink
Only add suffix if it is not set to false
Browse files Browse the repository at this point in the history
Removing the urlSuffix in Page.php by setting it to false works in source, but javascript adds it again. Resulting in link with undefined at the end.

**Setting URLSuffix to false, if page is published:**
```
public function getCMSFields()
{
      $fields = parent::getCMSFields();
        if( $this->isPublished() ) {
            $fields->FieldByName('Root.Main.URLSegment')->setURLSuffix(false);
        }
}
```
See issue: silverstripe#2723
silverstripe#2723
  • Loading branch information
RVXD authored Mar 4, 2022
1 parent 07df04f commit a1e410d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion client/src/legacy/SiteTreeURLSegmentField.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $.entwine('ss', function($) {
}

// Transfer current value to holder
this.find('.URL-link').attr('href', encodeURI(url + field.data('suffix'))).text(previewUrl);
this.find(".URL-link").attr("href", encodeURI(url + (field.data('suffix')?field.data('suffix'):''))).text(previewUrl);
},

/**
Expand Down

0 comments on commit a1e410d

Please sign in to comment.