-
Notifications
You must be signed in to change notification settings - Fork 65
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
Feature Request: Disable internal / same domain URLs #269
Comments
If it helps. While I don't use this plugin directly, you could look at implementing custom validation rules on an entry or if you have a linkfield in a matrix block, matrix block validation by checking the block type and linkit field type for the URL type and then doing a regex match with the primary site URL to catch these scenarios. We have a similar scenario where the URL field has used a hard coded domain for Entry content. I implemented custom validation errors to catch this scenario. You could also look at extending the validation rules of the linkfield as well to implement a similar outcome. |
@jamesmacwhite Thanks, those are some good ideas! A custom validation rule works for sure. I still think this should be a very common requirement (that many probably aren't even aware of). Having this as an option right in the plugin would make it easier and encourage best practices. |
I don't disagree with you on it being a useful feature, I just happened to come across your issue post while looking at this plugin and thought it was very similar to a scenario I had been working with, quite by chance really! I might end up looking at using this plugin instead of Linkit, given the bug with multi-site entry linking. |
Context
We want users to set links to Craft content by using Entry relations, not URLs, as it is more durable in case we later change the Entry URI format or migrate the domain.
At the same time we have to make the URL option available so they can link to external sites.
Suggestion
Add a check box in the URL options: "Prevent users from adding internal URL links"
When a user tries to save a URL that starts with the PRIMARY_SITE_URL, the validation fails with a message
"Could not save URL. For internal links, please select an entry instead of entering a URL"
The text was updated successfully, but these errors were encountered: