dev-master
9999999-dev https://github.com/Sam-Costigan/linkableobjectsModule for SilverStripe allowing Data Objects to be hooked into WYSIWYG link editor.
BSD-3-Clause
The Requires
by Sam Costigan
silverstripe
Module for SilverStripe allowing Data Objects to be hooked into WYSIWYG link editor.
Add your custom Data Objects to the HTML Editor Field link functionality, with a Dropdown field that is populated by relevant results as the user searches., (*1)
To set up a DataObject to be linkable, first it needs to implement the Linkable interface. There are two requirements for a Linkable DataObject: * a Link() function which will return a relevant URL to display the Data Object. * a LinkTitle() function which will return a title string to display when searching for Data Objects., (*2)
The Link() function will need to return a relevant URL so that the Data Object will be displayed. For more information on how to do this, see http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/, (*3)
When searching for DataObjects, the $searchable_fields array will be used to decide which fields are searched., (*4)
class Test extends DataObject implements Linkable { private static $db = array( 'Name' => 'Text', 'Author' => 'Varchar(150)' ); public static $searchable_fields = array( 'Name', 'Author' ); public function Link() { return $this->ID; } public function LinkTitle() { return $this->Name . ' - ' . $this->Author; } }
Once the DataObject has been set up to properly implement the Linkable interface, you need to add the following line to your mysite/_config.php file:, (*5)
HtmlEditorField_LinkObjects::addLinkableObject('Test');, (*6)
Your DataObject will then be added to the HTML Editor Field links section., (*7)
Feel free to make this module better by submitting feedback, changes, suggestions etc!, (*8)
Module for SilverStripe allowing Data Objects to be hooked into WYSIWYG link editor.
BSD-3-Clause
silverstripe