All stored links are displayed as http://www.domain.com
What is the best way for a new a newbie like me, to remove http:// from url display?

I would like to show all my links like www.domain.com

Any help woulb be most appreciated :-)

Thanks

Comments

dqd’s picture

Status: Active » Fixed

by typing it exactly like that ;)

the module support input converstion, depends on your title / url settings. But please use latest 7.x-1.x--dev of link module from now. It is strongly recommended to use it rather than alpha3, since in latest --dev push are already some of known issues fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

AniaMi’s picture

subs.

dqd’s picture

@AniaMi: please follow the new conventions: #1306444

btw: the issue was closed and the solution is sel-explaining by the options in the input area and by the options in manage field dialogs and its link widgets.

Every time when somebody adds a sub or 1+ or whatver I get a message to look for an issue and I don't have time for goose chases.

thanks 4 understanding.

emartin’s picture

A very dirty solution, but if it can help someone...

In link.module, ligne 475 (on version 7.x-1.0)

- $item['title'] = empty($title) ? $item['display_url'] : $title;
+ $item['title'] = empty($title) ? str_replace('http://', '', $item['display_url']) : $title;

emartin’s picture

A cleaner solution :

To override the default formatter, add this in your theme's template.php (replace YOURTHEME with your theme's name) :

/**
* Theme function for 'default' text field formatter.
* (Override of theme_link_formatter_link_default($vars) from link.module, line 748)
*/
function YOURTHEME_link_formatter_link_default($vars) {
$link_options = $vars['element'];
unset($link_options['element']['title']);
unset($link_options['element']['url']);

// Issue #1199806 by ss81: Fixes fatal error when the link URl is equal to page URL
if (isset($link_options['attributes']['class'])) {
$link_options['attributes']['class'] = array($link_options['attributes']['class']);
}

//Added code to remove http(s):// from link title
$vars['element']['title'] = !empty($vars['element']['title']) ? preg_replace('/^http(s)?:\/\//i', '', $vars['element']['title']) : $vars['element']['title'];

// Display a normal link if both title and URL are available.
if (!empty($vars['element']['title']) && !empty($vars['element']['url'])) {
return l($vars['element']['title'], $vars['element']['url'], $link_options);
}
// If only a title, display the title.
elseif (!empty($vars['element']['title'])) {
return check_plain($vars['element']['title']);
}
elseif (!empty($vars['element']['url'])) {
return l($vars['element']['title'], $vars['element']['url'], $link_options);
}
}

You can do similar override for the other formatters (following in link.module).

adam_b’s picture

Version: 7.x-1.0-alpha3 » 7.x-1.0
Category: support » bug
Status: Closed (fixed) » Active

Sorry to re-open this, but I'm using 7.x-1.0 and it always outputs the URL as http://www.domain.com, even when the field only has www.domain.com entered in it.

a. Could this be fixed?

b. Could there be a field-display option to display/hide the "http://" whether or not it's entered in the field? it seems like an obvious requirement, rather than editing the module or template files.

dqd’s picture

Status: Active » Closed (duplicate)

adam_b: At first ... this particular issue _is_ already fixed. Search the issue queue before opening an old issues and _please_ .... read the link module project page. If you have ideas for link URL validation options (and your scenario is one of those thousands), please post them in the issue posted on the project page. (No, I won't post the link here the 10.000st time).

Sorry but I am tired of the same issues again and again and again.
Thanks for understanding.

adam_b’s picture

Digidog, I have no desire to waste your time but, with respect,:

1. My experience is that this issue is not fixed - this was the only D7 reference I could find to the problem, but I've added a comment at #530884: Option for http://link input to link text without http:// missing

2. I've read the link module page which says:

Here are some examples of data input and the default view of a link: http://drupal.org results in http://drupal.org, but drupal.org results in http://drupal.org

but this doesn't agree with what you say in #530884: Option for http://link input to link text without http:// missing:

in D7 a link stored as 'www.domain.org.uk' appears as <a href="http://www.domain.org.uk">www.domain.org.uk</a>

dqd’s picture

adam_b,

I am sorry, I didn't want to sound barking. I just try to catch up with link module issue queue, but it seems like a story without an end. All I wish is to come to a actual timeline of issues. But as long as everybody throws in here and there what he/she momentary thinks of, we will have tons of dups flying around and loose overview.

The link I spoke about is and which can also be found on the project page is
#1318938: An all-embracing attempt for URL validation and Input / Output Form Filtering

Read this issue carefully and you will understand why this issue here is a duplicate. I will make this link more obvious on the project page now, because I DON'T want to see any filter/validation issue no more arising since this ^ issue is fixed or at least filled with some life. A community module lives from contribution and cooperation.

adam_b’s picture

I didn't take it personally, and I sympathize with the problem of a never-ending issue queue :)

I can see the relevance of that link now - I think I saw "URL validation" and mentally dismissed it as not what I was looking for. I'll let this closed issue rest in peace and take my comments to other threads.