October CMS resources and help articles

Simple and to the point. Optimized by the community.

Add links to Rich Editor search link section

1
by adam, last modified on July 7th, 2020

If you want to add links to the rich editor "choose link" section

The links will appear in this dropdown

In your plugin boot method add those two events.

Event::listen('backend.richeditor.listTypes', function () {
    return [
        'your_type' => 'Title',
    ];
});

Event::listen('backend.richeditor.getTypeInfo', function ($type) {
    if ($type === 'your_type') {
        return Model::getRichEditorTypeInfo($type);
    }   
});

In your model prepare the generate url logic.

public static function getRichEditorTypeInfo($type)
{
    if ($type == 'your_type') {
        $yourTypes = self::all();
        $selectOptions = [];  //array to populate with urls

        foreach ($yourTypes as $type) {
            $selectOptions['your url'] = [
                'title' => 'Your title',
                // 'items'=> additional items added as subsection
            ];
        }

        return $selectOptions;
    }

    return [];
}

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?