Create a custom field - URL
Allow for RELATIVE LINKS
If you put in an INTERNAL URL as the URL (relative link) it should open in the Current Browser, and not in a new browser.
On the click of the URL Field it always opens in a NEW TAB (even if it is an internal link)
Joomla 4.4.5
PHP 8
Here is the actual code:
if (!Uri::isInternal($value)) {
$attributes = ' rel="nofollow noopener noreferrer" target="blank"';
$text = Text::('JVISIT_WEBSITE');
} else {
$text = Text::_('JVISIT_LINK');
}
It seems that in the code it is 'hardcoded' to always use _blank
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Yes IsInternal does work if it is external. But if it is an internal link then it does not work. Is that what you are saying Brian?
Also I don't see the TARGET variable that you can define in the custom field build being referenced. Should it be? Similar to how you can select the target in a menu item?
thanks,
Laura
Yes IsInternal does work if it is external. But if it is an internal link then it does not work. Is that what you are saying Brian?
Not quite.
If you have configured the field not to use relative urls then isinternal does work
if you have configured the field to use relative urls then isinternal does not work
Also I don't see the TARGET variable that you can define in the custom field build being referenced. Should it be? Similar to how you can select the target in a menu item?
It's hard coded and as you point out correctly it should not be
Ok, got it. Interesting not sure why I would 'not use relative' when it is an internal link... since that would be the purpose of using relative URLs, so I can use an internal link within the site.
Do you know what the variable is for 'target' that is defined in the form? I could create a temporary override just for now until we have the fix.
-- Laura
It seems that the 'TARGET' is not part of core joomla, but there is still a bug...
I'm going to edit the request.
Labels |
Added:
bug
|
Ignoring the fact that target="_blank" should never be forced
I can confirm that if the field is set to use relative urls then the isInternal check will never pass so the target will be added.
If you do NOT use relative urls then the isInternal check does work