Initially we wanted to just 'strip' the display of 'mailto:' in custom fields.
Then we determined we wanted the URL to display various options such as:
We created an override that solves the issue:
`<?php
/**
$value = $field->value;
$desc = $field->description;
$mailto = "mailto:";
$value_substring = htmlspecialchars(str_replace("mailto:","",$value));
if ($value == '')
{
return;
}
$attributes = '';
/* Attributes defines whate attributes will be added to the link, such as opening in new window */
if (!JUri::isInternal($value))
{
$attributes = ' rel="nofollow noopener noreferrer" target="_blank"';
}
/* Define a variable: Link Display, this is the 'display' that will be shown.
--> If the description is Blank, assign the web url (or stripped email) to the linkdisplay
--> If it contains a value then use that value as the link display */
if ($desc =='')
{ $linkdisplay = $value_substring;
} else
{$linkdisplay = $desc;
}
/** code that works from 10/18/2018 */
echo sprintf('<a href="%s"%s>%s',
htmlspecialchars($value),
$attributes,
$linkdisplay
);`
Labels |
Added:
?
|
Status | New | ⇒ | Information Required |
You can do this in an layout override or creating your own custom field.
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-03-04 19:19:51 |
Closed_By | ⇒ | HLeithner |
We did solve this with an override, but it seems that others need a very similar functionality...especially having the 'mailto' stripped automatically.
thanks,
Laura
Ok so maybe you can create a PR against 4.0-dev?
HLeithner,
I haven't made a PR before, and I'm not sure if it is 'important' enough to do so, would you recommend that I just copy my code here, and create a PR?
thanks,
Laura
I think you need a bit more then a template override, you also need to modify the custom field settings.
Everyone has done a first PR ;-) just try it.
if you don't have a local dev Environment you can it do on github directly.
@HLeithner is this short Manual above somewhere to link so potential PR-Creators can be linked to?
There are better manuals then this.
Link?
Stripping away the mailto:
from the field is a nice touch, but not having to place it in the field at all would be my choice.
The default contact e-mail field is does not need a prefix, and it decodes the mail address structure and creates a link mailto:name@site
. Additionally, it is JavaScript encrypted. Can this be done for the mail address in the custom field, please?
@franz-wohlkoenig https://extensions.joomla.org/blog/item/how-to-contribute-to-joomla-through-github/ The screenshots are outdated, but the steps are consecutive and in principle is all correct.
@HLeithner can you please comment?