Skip to content

Commit

Permalink
Added SiteTreeURLSegmentField.ss template with Copy button
Browse files Browse the repository at this point in the history
  • Loading branch information
purplespider authored Feb 23, 2024
1 parent 3b30b07 commit ca842dc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ While it is possible to disable specific tweaks by removing the individual exten
## Templates
* __Email.ss:__ Sets font to sans-serif
* __ForgotPasswordEmail.ss:__ Changes the wording and format of the forgotten password e-mail to make it a bit friendlier.
* __SiteTreeURLSegmentField.ss:__ Adds a "Copy URL" button. To help stop users from copying the draft link.

## Modules
* __[wilr/silverstripe-googlesitemaps](https://github.com/wilr/silverstripe-googlesitemaps):__ Lets CMS users set certain (e.g. hidden) pages to not be indexed.
Expand Down
30 changes: 30 additions & 0 deletions templates/SilverStripe/CMS/Forms/SiteTreeURLSegmentField.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div class="preview-holder">
<a class="URL-link" href="$URL" target="_blank">
$URL
</a>
<div class="btn-group">
<button onclick="navigator.clipboard.writeText('{$URLPrefix}{$Value}')" role="button" type="button" class="btn btn-outline-secondary font-icon-link">Copy</button>
<% if not $IsReadonly %>
<button role="button" type="button" class="btn btn-outline-secondary edit">
<%t SilverStripe\CMS\Forms\SiteTreeURLSegmentField.Edit 'Edit' %>
</button>
<% end_if %>
</div>
</div>

<div class="edit-holder">
<div class="input-group">
<input $AttributesHTML />
<div class="input-group-append">
<button role="button" data-icon="accept" type="button" class="btn btn-primary update">
<%t SilverStripe\CMS\Forms\SiteTreeURLSegmentField.OK 'OK' %>
</button>
</div>
<div class="input-group-append">
<button role="button" data-icon="cancel" type="button" class="btn btn-outline-secondary btn-sm input-group-append cancel">
<%t SilverStripe\CMS\Forms\SiteTreeURLSegmentField.Cancel 'Cancel' %>
</button>
</div>
</div>
<% if $HelpText %><p class="form__field-description">$HelpText</p><% end_if %>
</div>

0 comments on commit ca842dc

Please sign in to comment.