Skip to content

Commit

Permalink
Merge pull request #38 from sheadawson/master
Browse files Browse the repository at this point in the history
1.2.1
  • Loading branch information
sheadawson committed Dec 13, 2015
2 parents 399ba18 + 45e5ff3 commit 4548fd0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ A Link Object can be linked to a URL or, an internal Page or File in the SilverS
### Example usage

```php
class Page extends SiteTree{
class Page extends SiteTree {

static $has_one = array(
private static $has_one = array(
'ExampleLink' => 'Link'
);

public function getCMSFields(){
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Link', LinkField::create('ExampleLinkID', 'Link to page or file'));

return $fields;
}

...
}
```

In your template, you can render the links anchor tag with
Expand All @@ -59,18 +61,20 @@ Use the EmbeddedObject/Field to easily add oEmbed content to a DataObject or Pag
### Example usage

```php
class Page extends SiteTree{
class Page extends SiteTree {

static $has_one = array(
private static $has_one = array(
'Video' => 'EmbeddedObject'
);

public function getCMSFields(){
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Video', EmbeddedObjectField::create('Video', 'Video from oEmbed URL', $this->Video()));

return $fields;
}

}
...
```

Expand Down
7 changes: 6 additions & 1 deletion code/dataobjects/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ public function forTemplate() {
$title = $this->Title ? $this->Title : $url; // legacy
$target = $this->getTargetAttr();
$class = $this->getClassAttr();
return "<a href='$url' $target $class>$title</a>";

$link = "<a href='$url' $target $class>$title</a>";

$this->extend('updateLinkTemplate', $this, $link);

return $link;
}
}

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
],
"require": {
"php": ">=5.3.2",
"silverstripe/framework": "3.2.*",
"silverstripe/cms": "3.2.*",
"unclecheese/display-logic": "1.3.*",
"silverstripe/framework": "^3.2",
"silverstripe/cms": "^3.2",
"unclecheese/display-logic": "^1",
"embed/embed": "~2.2.2"
},
"extra": {
Expand Down

0 comments on commit 4548fd0

Please sign in to comment.