Zazama / silverstripe-elemental-linkify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

silverstripe-elemental-linkify

Packagist Version GitHub

Introduction

silverstripe-elemental-linkify inserts a link type into TinyMCE where you can choose Elemental elements to link to. It also ships with a DBField that inserts a DropdownField into the CMS allowing you to choose both Page links or Elemental links.

Requirements

  • silverstripe/cms ^5

Installation

composer require zazama/silverstripe-elemental-linkify

Usage TinyMCE

Click on the link type "Element" which will open this window.

It will show a Dropdown with formatting: "[Pagename] Elementname"

TinyMCE

Usage Shortcode Field

<?php

use SilverStripe\ORM\DataObject;
use Zazama\ElementalLinkify\Fields\DBElementalLinkifyShortcode;
use Zazama\ElementalLinkify\Fields\ElementalLinkifyDropdownField;

class Teaser extends DataObject {
    // ...
    private static $db = [
        'TeaserLink' => DBElementalLinkifyShortcode::class
    ];

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

        // TeaserLink will be auto populated, but you can insert the dropdown yourself with
        $fields->addFieldToTab('Root.Something', ElementalLinkifyDropdownField::create('TeaserLink', 'TeaserLink'));

        return $fields;
    }
}

Dropdown

About

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:PHP 50.9%Language:JavaScript 49.1%