New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option or hook to remove "Link to entry" from dropdown #146
Comments
Speaking of module hooks, you can already use the |
Sweet, that worked like a charm! use craft\redactor\events\RegisterLinkOptionsEvent;
use craft\redactor\Field as RedactorField;
use yii\base\Event;
// Remove "Link to..." Redactor links
Event::on(
RedactorField::class,
RedactorField::EVENT_REGISTER_LINK_OPTIONS,
function(RegisterLinkOptionsEvent $event) {
// Only apply to a specific Redactor config
if ('Message.json' == $event->sender->redactorConfig) {
// Remove Craft's injected links
$event->linkOptions = [];
}
}
); I used If you only want to remove one specific source, you can pick it out manually. For reference, here's how Craft configures those extra links... [
0 => [
'optionTitle' => 'Link to an entry'
'elementType' => 'craft\\elements\\Entry'
'refHandle' => 'entry'
'sources' => [
0 => 'section:19870dc1-a51e-4134-bd5c-de55b11ddf2c'
1 => 'section:eca834a6-d8a1-4797-a552-e310f946eafb'
2 => 'section:128d6e4e-d02f-4247-83eb-a3841ca7ade5'
3 => 'section:c422ed50-9844-4531-854f-f8c505d92a05'
]
]
1 => [
'optionTitle' => 'Link to a category'
'elementType' => 'craft\\elements\\Category'
'refHandle' => 'category'
'sources' => [
0 => 'group:95e58ebd-aba6-48b8-adaf-ebae28ffbb7a'
1 => 'group:9bd9e19d-e53a-46eb-af47-2ce9a12a0ade'
]
]
] Thanks @andris-sevcenko! 🍺 |
Hello, In the Link to an Entry, would you know on how to filter the section entries based on user's tagged category? I only want to see all entries that is tagged to that category. Thank you very much. |
It would be nice if we could remove the "Link to entry" option from the dropdown menu. Ditto for "Link to category".
I don't even care how it's implemented (whether it's a field option, Redactor config, or requires a module hook). But it would be nice to have a bit more control over what users can link to.
Worth noting that this is not a new request...
The text was updated successfully, but these errors were encountered: