How to handle non CMS internal links
adrien-delhorme opened this issue · 3 comments
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?
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.
@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?
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?