PHPackages                             sheadawson/silverstripe-linkable - 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. sheadawson/silverstripe-linkable

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

sheadawson/silverstripe-linkable
================================

A couple of handy form fields and objects for managing external and internal links on DataObjects

2.1.2(1y ago)39316.2k↓27.3%69[17 issues](https://github.com/sheadawson/silverstripe-linkable/issues)[21 PRs](https://github.com/sheadawson/silverstripe-linkable/pulls)20BSD-3-ClausePHP

Since Sep 10Pushed 1y ago6 watchersCompare

[ Source](https://github.com/sheadawson/silverstripe-linkable)[ Packagist](https://packagist.org/packages/sheadawson/silverstripe-linkable)[ Docs](http://github.com/sheadawson/silverstripe-linkable)[ RSS](/packages/sheadawson-silverstripe-linkable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (4)Versions (46)Used By (20)

SilverStripe Linkable
=====================

[](#silverstripe-linkable)

This module is no longer maintained. Please checkout the following excellent alternatives

- [gorriecoe/silverstripe-link](https://github.com/gorriecoe/silverstripe-link)
- [gorriecoe/silverstripe-linkfield](https://github.com/gorriecoe/silverstripe-linkfield)
- [silverstripe-embed](https://github.com/gorriecoe/silverstripe-embed)

Requirements
------------

[](#requirements)

- SilverStripe 4.x
- [Display Logic](https://github.com/unclecheese/silverstripe-display-logic)

See 1.x branch/releases for SilverStripe 3.x support

Maintainers
-----------

[](#maintainers)

-

Description
-----------

[](#description)

This module contains a couple of handy FormFields / DataObjects for managing external and internal links on DataObjects, including oEmbed links.

Installation with [Composer](https://getcomposer.org/)
------------------------------------------------------

[](#installation-with-composer)

```
composer require "sheadawson/silverstripe-linkable"

```

Link / LinkField
----------------

[](#link--linkfield)

A Link Object can be linked to a URL, Email, Phone number, an internal Page or File in the SilverStripe instance. A DataObject, such as a Page can have many Link objects managed with a grid field, or one Link managed with LinkField.

### Example usage

[](#example-usage)

```
class Page extends SiteTree
{
	private static $has_one = [
		'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

```
$ExampleLink
```

### Adding custom class to link

[](#adding-custom-class-to-link)

The anchor tag can be rendered with a class or classes of your choosing by passing the class string to the `setCSSClass()` method within your template.

```
$ExampleLink.setCSSClass(your-css-class)
```

### Customising link templates

[](#customising-link-templates)

Link tags are rendered with the Link.ss template. You can override this template by copying it into your theme or project folder and modifying as required.

You can also specify a custom template to render any Link with by calling the renderWith function and passing in the name of your custom template

```
$ExampleLink.renderWith(Link_button)
```

Finally, you can optionally offer CMS users the ability to select from a list of templates, allowing them to choose how their Link should be rendered. To enable this feature, create your custom template files and register them in your site config.yml file as below.

```
Sheadawson\Linkable\Models\Link:
  templates:
    button: Description of button template # looks for Link_button.ss template
    iconbutton: Description of iconbutton template # looks for  Link_iconbutton.ss template
```

### Limit allowed Link types

[](#limit-allowed-link-types)

To limit link types for each field.

```
LinkField::create('ExampleLinkID', 'Link Title')->setAllowedTypes(array('URL','Phone'))
```

You can also globally limit link types. To limit types define them in your site config.yml file as below.

```
Sheadawson\Linkable\Models\Link:
  allowed_types:
    - URL
    - SiteTree
```

The default types available are:

```
URL: URL
Email: Email address
Phone: Phone number
File: File on this website
SiteTree: Page on this website
```

### Adding custom Link types

[](#adding-custom-link-types)

Sometimes you might have custom DataObject types that you would like CMS users to be able to create Links to. This can be achieved by adding a DataExtension to the Link DataObject, see the below example for making Product objects Linkable.

```
class CustomLink extends DataExtension
{
    private static $has_one = [
        'Product' => 'Product',
    ];

    private static $types = [
        'Product' => 'A Product on this site',
    ];

    public function updateCMSFields(FieldList $fields)
    {
		// update the Link Type dropdown to contain your custom Link types
        $fields->dataFieldByName('Type')->setSource($this->owner->config()->types);

		// Add a dropdown field containing your ProductList
		$fields->addFieldToTab(
            'Root.Main',
            DropdownField::create('ProductID', 'Product', Product::get()->map('ID', 'Title')->toArray())
                ->setHasEmptyDefault(true)
                ->displayIf('Type')->isEqualTo('Product')->end()
        );
	}
```

In your config.yml

```
Sheadawson\Linkable\Models\Link:
  extensions:
    - CustomLink
```

Please see the [wiki](https://github.com/sheadawson/silverstripe-linkable/wiki) for more customisation examples.

EmbeddedObject/Field
--------------------

[](#embeddedobjectfield)

Use the EmbeddedObject/Field to easily add oEmbed content to a DataObject or Page.

### Example usage

[](#example-usage-1)

```
class Page extends SiteTre
 {
	private static $has_one = [
		'Video' => 'EmbeddedObject',
	];

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

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

		return $fields;
	}
}
	...
```

In your template, you can render the object with the name of the has\_one relation

```
$Video
```

You can also access other metadata on the object via

```
$Video.Title
$Video.Description
$Video.ThumbURL
```

See EmbeddedObject.php for a list of properties saved available in $db.

Custom query params
-------------------

[](#custom-query-params)

Sometimes you may want to add custom query params to the GET request which fetches the `LinkEditForm`. This is very useful in a situation where you want to customise the form based on specific situation. Custom query params are a way how to provide context for your `LinkEditForm`.

To add custom params you need to add `data-extra-query`.

```
$linkField->setAttribute('data-extra-query', '&param1=value1');

```

You can then use the `updateLinkForm` extension point and extract the param value with following code:

```
$param1 = Controller::curr()->getRequest()->requestVar('param1');

```

Development
-----------

[](#development)

Front end uses pre-processing and requires the use of `Yarn`.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance25

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community40

Growing community involvement

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 57.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~147 days

Recently: every ~562 days

Total

28

Last Release

655d ago

Major Versions

0.1.0 → 1.0.02014-12-03

1.3.x-dev → 2.0.02018-06-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ca23b453a4fc5ac237ad4fcc512f68fab5c7b124f403cad1a5848b3fffb6aa2?d=identicon)[sheadawson](/maintainers/sheadawson)

---

Top Contributors

[![sheadawson](https://avatars.githubusercontent.com/u/1166136?v=4)](https://github.com/sheadawson "sheadawson (96 commits)")[![gorriecoe](https://avatars.githubusercontent.com/u/11811440?v=4)](https://github.com/gorriecoe "gorriecoe (18 commits)")[![fonsekaean](https://avatars.githubusercontent.com/u/143939?v=4)](https://github.com/fonsekaean "fonsekaean (8 commits)")[![nyeholt](https://avatars.githubusercontent.com/u/161730?v=4)](https://github.com/nyeholt "nyeholt (4 commits)")[![DrMartinGonzo](https://avatars.githubusercontent.com/u/11061711?v=4)](https://github.com/DrMartinGonzo "DrMartinGonzo (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![grgcnnr](https://avatars.githubusercontent.com/u/2694014?v=4)](https://github.com/grgcnnr "grgcnnr (3 commits)")[![Leapfrognz](https://avatars.githubusercontent.com/u/1740262?v=4)](https://github.com/Leapfrognz "Leapfrognz (3 commits)")[![satrun77](https://avatars.githubusercontent.com/u/166450?v=4)](https://github.com/satrun77 "satrun77 (3 commits)")[![vinstah](https://avatars.githubusercontent.com/u/4538082?v=4)](https://github.com/vinstah "vinstah (2 commits)")[![mfendeksilverstripe](https://avatars.githubusercontent.com/u/26395487?v=4)](https://github.com/mfendeksilverstripe "mfendeksilverstripe (2 commits)")[![rsmclaren](https://avatars.githubusercontent.com/u/1579625?v=4)](https://github.com/rsmclaren "rsmclaren (2 commits)")[![martinduparc](https://avatars.githubusercontent.com/u/839534?v=4)](https://github.com/martinduparc "martinduparc (2 commits)")[![HeyImPhil](https://avatars.githubusercontent.com/u/4695076?v=4)](https://github.com/HeyImPhil "HeyImPhil (2 commits)")[![sunnysideup](https://avatars.githubusercontent.com/u/167154?v=4)](https://github.com/sunnysideup "sunnysideup (2 commits)")[![ivoba](https://avatars.githubusercontent.com/u/471254?v=4)](https://github.com/ivoba "ivoba (2 commits)")[![wilr](https://avatars.githubusercontent.com/u/101629?v=4)](https://github.com/wilr "wilr (1 commits)")[![DorsetDigital](https://avatars.githubusercontent.com/u/15108750?v=4)](https://github.com/DorsetDigital "DorsetDigital (1 commits)")[![hdpero](https://avatars.githubusercontent.com/u/13778690?v=4)](https://github.com/hdpero "hdpero (1 commits)")[![jason-zz](https://avatars.githubusercontent.com/u/6354744?v=4)](https://github.com/jason-zz "jason-zz (1 commits)")

---

Tags

linksilverstripecms

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sheadawson-silverstripe-linkable/health.svg)

```
[![Health](https://phpackages.com/badges/sheadawson-silverstripe-linkable/health.svg)](https://phpackages.com/packages/sheadawson-silverstripe-linkable)
```

###  Alternatives

[burnbright/silverstripe-externalurlfield

Provides SilverStripe with a DBField and FormField for handling external URLs.

109.6k1](/packages/burnbright-silverstripe-externalurlfield)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
