[英]Custom URL field in Joomla - Remove mailto prefix
in Joomla I use a URL custom field (MAILTO schema) to display an email address. 在Joomla中,我使用URL自定义字段(MAILTO模式)来显示电子邮件地址。 The problem is that Joomla insert mailto prefix twice in the code: once in href attribute and another one between link tags, like this:
问题是Joomla在代码中两次插入了mailto前缀:一次在href属性中,另一个在链接标记之间,如下所示:
<span class="field-value"><a href="mailto:myEmail@some.site" rel="nofollow" target="_blank">mailto:myEmail@some.site</a></span>
...and this is php code that manage its display: ...这是管理其显示的php代码:
defined('_JEXEC') or die;
$value = $field->value;
if ($value == '')
{
return;
}
$attributes = '';
if (!JUri::isInternal($value))
{
$attributes = ' rel="nofollow noopener noreferrer" target="_blank"';
}
echo sprintf('<a href="%s"%s>%s</a>',
htmlspecialchars($value),
$attributes,
htmlspecialchars($value)
);
I would like to remove mailto prefix between link tags. 我想删除链接标记之间的mailto前缀。
How to proceed? 如何进行? … perhaps with a regex rule?
……也许有正则表达式规则? Problem, I'm not a developer…
问题,我不是开发人员…
Thank you for your help, 谢谢您的帮助,
Lorenzo 洛伦佐
Thank you for your Reply,I think you can try again. 多谢您的回覆,我想您可以再试一次。
My English is a little bad,some places may be Unclear expression. 我的英语有点不好,有些地方表达不清楚。 enter image description here
在此处输入图片说明
echo sprintf('<a href="%s"%s>%s</a>',
preg_replace("/(^(http|https|ftp):\/\/)|(^mailto:)/i","",htmlspecialchars($value)),
$attributes,
htmlspecialchars($value));
// you can test it
$value = "http://www.kinoki.at";
$value = "mailto:info@kinoki.at";
echo "<pre>";
print_r( preg_replace("/(^(http|https|ftp):\/\/)|(^mailto:)/i","",htmlspecialchars($value)));
echo "<pre>";exit;
You likely run into this issue because Joomla tries to cloak the e-mail address. 您可能会遇到此问题,因为Joomla试图掩盖电子邮件地址。 Best would be to use the recommended way of showing the e-mail address, using the built-in e-mail cloaking functions.
最好的方法是使用内置的电子邮件隐藏功能,使用推荐的方式显示电子邮件地址。
echo JHtml::_('email.cloak', $value);
See also: https://docs.joomla.org/How_to_cloak_email_addresses 另请参阅: https : //docs.joomla.org/How_to_cloak_email_addresses
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.