PHPackages                             arillo/silverstripe-links - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arillo/silverstripe-links

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

arillo/silverstripe-links
=========================

Add links to any DataObject

2.0.1(1y ago)0700MITPHPCI failing

Since Nov 2Pushed yesterday3 watchersCompare

[ Source](https://github.com/arillo/silverstripe-links)[ Packagist](https://packagist.org/packages/arillo/silverstripe-links)[ Docs](https://github.com/arillo/silverstripe-links)[ RSS](/packages/arillo-silverstripe-links/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (13)Used By (0)

Arillo\\Links
=============

[](#arillolinks)

[![Latest Stable Version](https://camo.githubusercontent.com/7343865ec87f7569e8670eb3dcb906f6180f9b86218a3a9696446194089c022f/68747470733a2f2f706f7365722e707567782e6f72672f6172696c6c6f2f73696c7665727374726970652d6c696e6b732f762f737461626c653f666f726d61743d666c6174)](https://packagist.org/packages/arillo/silverstripe-links) [![Total Downloads](https://camo.githubusercontent.com/8aca4d718fa8b198860a054762bdf80b1124881e4e3f2d13a67d7eaf9a2fa3c0/68747470733a2f2f706f7365722e707567782e6f72672f6172696c6c6f2f73696c7665727374726970652d6c696e6b732f646f776e6c6f6164733f666f726d61743d666c6174)](https://packagist.org/packages/arillo/silverstripe-links)

Add links to any DataObject.

### Requirements

[](#requirements)

SilverStripe CMS ^6.0

Installation
------------

[](#installation)

```
composer require arillo/silverstripe-links
```

Usage
-----

[](#usage)

Attach the `Arillo\Links\LinkExtension` to your DataObject via `config.yml`:

```
MyDataObject:
  extensions:
    - Arillo\Links\LinkExtension

```

```
use SilverStripe\ORM\DataObject;
use Arillo\Links\Link;
use Arillo\Links\LinkExtension;

class MyDataObject extends DataObject
{
    public function getCMSFields()
      {
          $this->beforeUpdateCMSFields(function($fields) {
              // in case you use Link::EDITMODE_PLAIN, you might need
              // to remove the link relation field generated by the scaffolder.
              $fields->removeByName(LinkExtension::FIELD . 'ID')
              $fields->addFieldsToTab(
                  'Root.Main',
                  // add link fields directly to the belonging DataObject.
                  Link::edit_fields(
                      $this,
                      [
                          'mode' => Link::EDITMODE_PLAIN,
                          'showLinkTitle' => true,
                      ]
                  )

                  // or use default editing via HasOneButtonField
                  Link::edit_fields($this)
              );
          });
          return parent::getCMSFields();
      }
}
```

Inspect `Arillo\Links\Link::DEFAULT_FIELDS_CONFIG` for all available config keys.

A link can be rendered in templates like this:

```

    $Title

```

or use the template of the module:

```

```

Extending
---------

[](#extending)

Since version 1.x extensibility should have become easier. In this example we are adding the ability to create anchor links to [elements](https://github.com/arillo/silverstripe-elements):

```
