XF 1.4 Custom user fields , URL clickable

Anton_Bodryachkom

Active member
Hi Forum , is it possible to make clickable URL/link when entered to Custom fields ?
example: TEST URL: https://xenforo.com/community
So https://xenforo.com/community would be hyperlink
c61ebe32fc877361eeef608ce19bff64.png


thnk you
 
Yes.

When editing the field, under "General Options" you can specify a template in the "Value Display HTML" field, e.g.

HTML:
<a href="{$valueUrl}">{$value}</a>
 
  • Like
Reactions: sbj
There must be something else on that page giving that error, or something else that isn't set right.

There's no validation, as such, on that field. It should accept anything, so it must be some other field that doesn't have a valid value.

It's worth noting that add-ons can sometimes cause this behavior so if you can't immediately see the problem, try disabling all add-ons and try again.
 
Sorry to hijack your thread @Anton_Bodryachkom , I have another question.

So I did this:
Code:
<a href="{$valueUrl}" target="_blank">{$value}</a>
but it doesn't work.
The opened page always is like:
Code:
www.MyForumName.com/{$value}

So it puts all the time my forums' url-name in front of the valid url.

What is wrong here @Chris D ?
 
I apologise it should be:

HTML:
<a href="{$value}" target="_blank">{$value}</a>

{$valueUrl} would be used if it was, for example, some sort of parameter that should go inside a URL. Otherwise the {$value} should be used instead.
 
I apologise it should be:

HTML:
<a href="{$value}" target="_blank">{$value}</a>

{$valueUrl} would be used if it was, for example, some sort of parameter that should go inside a URL. Otherwise the {$value} should be used instead.
No need to apologise. You are trying to help, thanks.
Just... it still gives the same error. Strange.
 
For people who have the same issue:

The version I posted in my last post definitely works for me.
I identified the problem. If you just enter:
Code:
www.mywebsite.com
mywebsite.com
It won't work. At least it doesn't work for me.
It requires the user to put in the full url with http in front of it:
Code:
http://www.mywebsite.com
Then it works. What a bad behaviour... Which user would do that?...

Anyway, I bypassed this by doing:

Code:
<a href="http://{$valueUrl}" target="_blank">{$value}</a>
 
A URL is technically only valid if it includes the scheme such as http://

You should set the value match requirements to URL which would assert a valid URL is entered and remove the http:// bit from the display value.
 
  • Like
Reactions: sbj
A URL is technically only valid if it includes the scheme such as http://

You should set the value match requirements to URL which would assert a valid URL is entered and remove the http:// bit from the display value.
Well, I never ever use the http:// way when I type in a link. It took a bit to realize that this is the problem.

And with matching requirements to URL, the display of url in message user info is that big long http://www. displaying.
As you may know the message user info on left side has almost no space. It takes 3 lines to display a domain with 10 characters. And it looks ugly.
At least my way, you can save 7 characters (http://) + 3 characters (www, depends on your redirecting). So now my method displays mywebsite.com in 1 line, whereas the normal way displays it as http:///www.mywebsite.com in 3 lines.

But thanks, I learned a new thing today. I didn't know about the {$value} method for custom user fields.
 
Well, I never ever use the http:// way when I type in a link. It took a bit to realize that this is the problem.

And with matching requirements to URL, the display of url in message user info is that big long http://www. displaying.
As you may know the message user info on left side has almost no space. It takes 3 lines to display a domain with 10 characters. And it looks ugly.
At least my way, you can save 7 characters (http://) + 3 characters (www, depends on your redirecting). So now my method displays mywebsite.com in 1 line, whereas the normal way displays it as http:///www.mywebsite.com in 3 lines.

But thanks, I learned a new thing today. I didn't know about the {$value} method for custom user fields.
Problem is though you can't always assume a URL will be prefixed with http:// (it might be https://) and you can't always assume that www. will work. Adding either of these things technically make it a completely different URL. Also your method won't stop people from adding the http:// or www. again. So that will really break things.

You can't have it all ways. If you want it to be a URL it must be asserted as a valid URL or expect it to be broken.
 
  • Like
Reactions: sbj
Back
Top Bottom