PHPackages                             zirak/linkable-dataobjects - 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. zirak/linkable-dataobjects

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

zirak/linkable-dataobjects
==========================

This module adds the ability to link DataObjects in TinyMCE

1.2(8y ago)7719[1 issues](https://github.com/g4b0/silverstripe-linkable-dataobjects/issues)GPL-2JavaScriptCI failing

Since May 14Pushed 5y ago2 watchersCompare

[ Source](https://github.com/g4b0/silverstripe-linkable-dataobjects)[ Packagist](https://packagist.org/packages/zirak/linkable-dataobjects)[ RSS](/packages/zirak-linkable-dataobjects/feed)WikiDiscussions master Synced 1w ago

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

Linkable DataObjects
====================

[](#linkable-dataobjects)

Linkable DataObjects is a module that permit to link DataObjects from TinyMCE.

Introduction
------------

[](#introduction)

Pages are not always the better way to implement things. For example site news can grow rapidly and the first side effect would be a big and difficult to manage SiteTree. DataObjects help maintaining things clean and straight, but unfortunately they are not included in frontend search. This module let you insert DataObject in search.

This module add the ability to link DataObjects through TinyMCE, just like internal pages. The linkable DataObjects must obviously implement a Link() function.

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

[](#requirements)

- SilverStripe &gt;=3.1 &lt;4.0

### Installation

[](#installation)

Install the module through [composer](http://getcomposer.org):

```
composer require zirak/linkable-dataobjects
composer update

```

Make the DataObject implement Linkable interface (you need to implement Link(), LinkLabel(), link\_shortcode\_handler():

```
class DoNews extends DataObject implements Linkable {

	private static $db = array(
			'Title' => 'Varchar',
			'Subtitle' => 'Varchar',
			'News' => 'HTMLText',
			'Date' => 'Date',
	);
	private static $has_one = array(
			'Page' => 'PghNews'
	);

	/**
	* Link to this DO
	* @return string
	*/
 public function Link() {
	 return $this->Page()->Link() . 'read/' . $this->ID;
 }

 /**
	* Label displayed in "Insert link" menu
	* @return string
	*/
 public static function LinkLabel() {
	 return 'News';
 }

 /**
	* Replace a "[{$class}_link,id=n]" shortcode with a link to the page with the corresponding ID.
	* @param array  $arguments Arguments to the shortcode
	* @param string $content   Content of the returned link (optional)
	* @param object $parser    Specify a parser to parse the content (see {@link ShortCodeParser})
	* @return string anchor Link to the DO page
	*
	* @return string
	*/
 static public function link_shortcode_handler($arguments, $content = null, $parser = null) {
	 if (!isset($arguments['id']) || !is_numeric($arguments['id'])) {
		 return;
	 }

	 $id =  $arguments['id'];
	 $do = DataObject::get_one(__CLASS__, "ID=$id");

	 if (!$do) {
		 $do = DataObject::get_one('ErrorPage', '"ErrorCode" = \'404\'');
		 return $do->Link();
	 }

	 if ($content) {
		 return sprintf('%s', $do->Link(), $parser->parse($content));
	 } else {
		 return $do->Link();
	 }
 }
}
```

Here you are a sample page holder, needed to implement the Link() function into the DataObject:

```
class PghNews extends Page {

	private static $has_many = array(
			'News' => 'DoNews'
	);

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

		/* News */
		$gridFieldConfig = GridFieldConfig_RelationEditor::create(100);
		// Remove unlink
		$gridFieldConfig->removeComponentsByType('GridFieldDeleteAction');
		// Add delete
		$gridFieldConfig->addComponents(new GridFieldDeleteAction());
		// Remove autocompleter
		$gridFieldConfig->removeComponentsByType('GridFieldAddExistingAutocompleter');
		$field = new GridField(
						'Faq', 'Faq', $this->News(), $gridFieldConfig
		);
		$fields->addFieldToTab('Root.News', $field);

		return $fields;
	}
}

class PghNews_Controller extends Page_Controller {

	private static $allowed_actions = array(
			'read'
	);

	public function read(SS_HTTPRequest $request) {
		$arguments = $request->allParams();
		$id = $arguments['ID'];

		// Identifico la faq dall'ID
		$Object = DataObject::get_by_id('DoNews', $id);

		if ($Object) {
			//Popolo l'array con il DataObject da visualizzare
			$Data = array($Object->class => $Object);
			$this->data()->Title = $Object->Title;

			$themedir = $_SERVER['DOCUMENT_ROOT'] . '/' . SSViewer::get_theme_folder() . '/templates/';
			$retVal = $this->Customise($Data);
			return $retVal;
		} else {
			//Not found
			return $this->httpError(404, 'Not found');
		}
	}
}
```

### Register your shortcode handlers in your \_config.php

[](#register-your-shortcode-handlers-in-your-_configphp)

```
:::php
ShortcodeParser::get('default')->register('yournamespace_yourclass_link', array('YourNamespace\YourClass', 'link_shortcode_handler'));

```

Flush your cache and start linking your DataObjects.

### Suggested modules

[](#suggested-modules)

- Searchable DataObjects:

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 78.9% 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 ~699 days

Total

3

Last Release

2989d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/11ee3ded134711b9ff1d704b1d448a7d3fdfe1b5f5b2e2809cda7eeac8356de5?d=identicon)[g4b0](/maintainers/g4b0)

---

Top Contributors

[![g4b0](https://avatars.githubusercontent.com/u/2427390?v=4)](https://github.com/g4b0 "g4b0 (15 commits)")[![steiha](https://avatars.githubusercontent.com/u/2902528?v=4)](https://github.com/steiha "steiha (2 commits)")[![danielpina](https://avatars.githubusercontent.com/u/2507440?v=4)](https://github.com/danielpina "danielpina (1 commits)")[![sphire](https://avatars.githubusercontent.com/u/508?v=4)](https://github.com/sphire "sphire (1 commits)")

---

Tags

linksilverstripetinymcedataobject

### Embed Badge

![Health badge](/badges/zirak-linkable-dataobjects/health.svg)

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

###  Alternatives

[sheadawson/silverstripe-linkable

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

39316.2k24](/packages/sheadawson-silverstripe-linkable)[burnbright/silverstripe-externalurlfield

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

109.6k1](/packages/burnbright-silverstripe-externalurlfield)[sunnysideup/typography

Add a typography test page to your silverstripe website / application.

124.2k3](/packages/sunnysideup-typography)

PHPackages © 2026

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