?
avatar rytechsites
rytechsites
9 Nov 2018

Is your feature request related to a problem? Please describe.

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:

  1. Display 'text' instead of the actual URL
  2. Display the actual URL
  3. always strip the 'mailto:' code from the display
  4. would also be nice to add option to display 'title' along with the text if needed.

Describe the solution you'd like

We created an override that solves the issue:

`<?php
/**

  • @Package Joomla.Plugin
  • @subpackage Fields.URL
  • @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
  • @license GNU General Public License version 2 or later; see LICENSE.txt
    */
    defined('_JEXEC') or die;

$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
);`

Additional context

avatar rytechsites rytechsites - open - 9 Nov 2018
avatar joomla-cms-bot joomla-cms-bot - change - 9 Nov 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 9 Nov 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 4 Mar 2019
Status New Information Required
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 4 Mar 2019

@HLeithner can you please comment?

avatar HLeithner
HLeithner - comment - 4 Mar 2019

You can do this in an layout override or creating your own custom field.

avatar HLeithner HLeithner - change - 4 Mar 2019
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2019-03-04 19:19:51
Closed_By HLeithner
avatar HLeithner HLeithner - close - 4 Mar 2019
avatar rytechsites
rytechsites - comment - 4 Mar 2019

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

avatar HLeithner
HLeithner - comment - 4 Mar 2019

Ok so maybe you can create a PR against 4.0-dev?

avatar rytechsites
rytechsites - comment - 4 Mar 2019

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

avatar HLeithner
HLeithner - comment - 4 Mar 2019

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.

  • fork joomla-cms
  • clone it to your local pc
  • create a new branch from 4.0-dev
  • modify the files you have to
  • push it back to github
  • create a pull request

if you don't have a local dev Environment you can it do on github directly.

  • fork joomla-cms
  • create a new branch from 4.0-dev
  • modify the files you have to in the webeditor
  • create a pull request
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Mar 2019

@HLeithner is this short Manual above somewhere to link so potential PR-Creators can be linked to?

avatar HLeithner
HLeithner - comment - 5 Mar 2019

There are better manuals then this.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Mar 2019

Link?

avatar kofaysi
kofaysi - comment - 12 Mar 2019

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?

avatar kofaysi
kofaysi - comment - 12 Mar 2019

@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.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 13 Mar 2019

@kofaysi thanks for Link. Will save it for similaer Questions.

Add a Comment

Login with GitHub to post a comment