django-cms / djangocms-link

django CMS Link is a plugin for django CMS that allows you to add links on your site.
https://marketplace.django-cms.org/en/addons/browse/djangocms-link/
Other
34 stars 61 forks source link

How to handle non CMS internal links #128

Closed adrien-delhorme closed 5 years ago

adrien-delhorme commented 7 years ago

I need to make a link to an internal page, that is not managed in the CMS (eg: an aldryn newsblog article). The external_link field requires me to add a domain name at the beginning of my link, but I would prefer to have my links starting at / (eg: /my-page/ instead of http://mydomain.com/my-page/).

Is it possible to manage this with DJANGOCMS_LINK_INTRANET_HOSTNAME_PATTERN?

jrief commented 7 years ago

As far as I know, you have to create your own plugin in order to do this.

This, btw. was one of the reasons I added an alternative link plugin to djangocms-cascade. There you can extend the link plugin and allow targets other than CMS pages, for instance your own Django models providing their own get_absolute_url() method.

FinalAngel commented 7 years ago

@adrien-delhorme thanks for the info, I've encountered this issues some times myself, the external_link is a regular Django URL field. We could eventually extend or allow internal link to accept these values.

It is not possible atm though, any change you might propose a PR?

adrien-delhorme commented 7 years ago

IntranetURLValidator inherit from URLValidator which requires the URL to have a scheme (http, https, ...). To allow internal URLs, starting at the root /, we need to overwrite all the __call__ method just to avoid the scheme validation. Does it sound a good solution to you?