This module provides a Link model and CMS interface for managing different types of links. Including:
- Emails
- External links
- Links to pages within the CMS
- Links to assets within the CMS
- Phone numbers
Installation via composer.
composer require silverstripe/linkfieldcomposer require silverstripe/linkfield:^2
composer require silverstripe/linkfield:^1<?php
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\LinkField\ORM\DBLink;
use SilverStripe\LinkField\Models\Link;
use SilverStripe\LinkField\Form\LinkField;
class Page extends SiteTree
{
private static array $db = [
'DbLink' => DBLink::class
];
private static array $has_one = [
'HasOneLink' => Link::class,
];
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldsToTab(
'Root.Main',
[
LinkField::create('HasOneLink'),
LinkField::create('DbLink'),
]
)
return $fields;
}
}Please be aware that in early versions of this module (and in untagged dev-master) there were no table names defined
for our Link classes. These have now all been defined, which may mean that you need to rename your old tables, or
migrate the data across.
EG: SilverStripe_LinkField_Models_Link needs to be migrated to LinkField_Link.
https://github.com/sheadawson/silverstripe-linkable
Shae Dawson's Linkable module was a much loved, and much used module. It is, unfortunately, no longer maintained. We have provided some steps and tasks that we hope can be used to migrate your project from Linkable to LinkField.