Skip to content

Commit 26f4682

Browse files
Working release
1 parent 906d732 commit 26f4682

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A small SilverStripe module that provides logged in users with a front-end `Edit
44

55
## Setup
66

7-
Add this par to your project's `composer.json` file
7+
Add this part to your project's `composer.json` file
88

99
```composer
1010
"repositories": [
@@ -23,11 +23,13 @@ Add the extension to your site's yml configuration
2323

2424
Page:
2525
extensions:
26-
- CMSEditLink
26+
- evanshunt\CMSEditLink\CMSEditLink
2727

2828
```
2929

30-
Then on your `Page.ss` or if you only want to enabel it on specific pages, then only add it to those pages' templates; add `$EditURL()`. This will render a small link on the page. Right now it's positioned fixed at the bottom left corner of the page.
30+
On `Page.php` controller add `use evanshunt\CMSEditLink;`
31+
32+
Then on your `Page.ss` or if you only want to enabel it on specific pages; then only add it to those pages' templates, add `$EditURL`. This will render a small link on the page. Right now it's positioned fixed at the bottom left corner of the page.
3133

3234
Changelog:
3335

src/CMSEditLink.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
11
<?php
2+
namespace evanshunt\CMSEditLink;
23

34
use SilverStripe\ORM\DataExtension;
4-
use Silverstripe\Security\Security;
55
use SilverStripe\ORM\FieldType\DBField;
6+
use SilverStripe\ORM\FieldType\DBHTMLText;
7+
use SilverStripe\Security\Security;
8+
69

710
use SilverStripe\Dev\Debug;
811

912
class CMSEditLink extends DataExtension
1013
{
11-
private static $db = [
12-
13-
];
14-
15-
private static $many_many = array(
16-
);
17-
18-
private static $has_one = [];
19-
20-
private static $hide_ancestor = 'Page';
21-
private static $table_name = 'CMSEditLink';
22-
23-
2414

2515
public function EditURL(){
2616

2717
if ($member = Security::getCurrentUser()) {
28-
return DBField::create_field(HTMLFragment::class,"<a href='admin/pages/edit/show/".$this->owner->ID."/' style='
18+
return DBField::create_field('HTMLFragment',"<a href='admin/pages/edit/show/".$this->owner->ID."/' style='
2919
position: fixed;
3020
z-index: 1000;
3121
bottom: 0;
@@ -36,6 +26,8 @@ public function EditURL(){
3626
color: #fff;
3727
' target='_blank' rel='nofollow'>Edit</a>");
3828
}
29+
30+
return NULL;
3931
}
4032

4133
}

0 commit comments

Comments
 (0)