1

I have a multi-site setup, and when using Redactor's Link to an entry function, by default, site identifiers are added to the link href:

href="https://mysite/my-page#entry:4223@3:url"

I would like to prevent (or strip out) the @3 site identifier, because I wish to use the current site's base URL, rather than specify a specific site's base URL be used. Is this possible?

1 Answer 1

1

I solved this by creating a Redactor plugin that listens for the link.inserted event and strips out the site identifer:

craft/config/redactor/plugins/myplugin.js:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        onlink: {
            inserted: function(link) { 
                link.nodes.forEach(node => node.href = node.href.replace(/@\d+/, ''))
             },
        },
    });
})(Redactor);

craft/config/redactor/redactorFieldConfig.json:

{
    "plugins": ["myplugin"]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.