URL without "http://www."

I just wondered if there is a kirby helper or something similar to output an URL without the http://www. If I insert a link and output it as kirbytext, the links are formated like this.
But I have a single field with type=url. So is this possible?

I don’t know of any kirby helper, but you could use preg_replace() to remove the unwanted parts of the URL. Check out this thread on SO for some ideas.

Thanks for the short answer. I’m aware of the preg_replace. I just thought there is maybe a native kirby way of doing this. Because it is also done with de link tag in kirbytext.

You can remove the protocol with url::host($url) but that would still leave you with the subdomain. Are you telling us that Kirby always adds www to an URL, even if you haven’t added it. Can you give an example of your content in your content file?

No, my point was, that kirby removes the http and www in kirbytext formatted fields. If I enter:
(link: http://www.domain.com)
kirby outputs it like domain.com

Of course I could insert it without www. But the clients are used the www :wink:

But i solved it now with your suggested stack overflow solution. That works great.

Kirby uses url::short($text) to generate the text in the link tag. You could make a copy of the link tag and remove this behaviour. Does not help with the url field though.

I dont know if im Right or Wrong. But Like in Plesk, you can Select a Option For your Domain Like http://www.example.de or www.example.de or Just example.de. it means you can Change the Option :slight_smile: to whatever you Like :slight_smile:

@thesmithy: Yeah, but this has nothing to do with @jonathanhess’s problem. The link tag returns a short url, while the url field does not.

Okay i understand :slight_smile:

@texnixe: My goal is to get a shortlink without the subdomain ‘www’ and the ‘http://’ for the url field. So an url with the link tag and the url field are displayed the same way. I want to have consistency for all links.
But as I said with the preg_replace() I got what I aimed for.

Ok, ok, now I finally fully understand. I have corrected it above.

is it possible to not shorten the link-text in a textarea-field?
(link: https://www.myurl.de text: https://www.myurl.de popup: yes)
i would like to show the complete url inclusive protocol…

1 Like

As already mentioned above, you can make a copy of the Kirbytag and modify your version, overwriting the original link tag.

hmm, i don’t understand this behavior.

if i don’t like the protocol in the output, i don’t have to write it and i can set it up like
(link: https://www.myurl.de text: myurl.de)
if i set the text to https://www.myurl.de, i expect to get this as the result.

if i understand you, i can update the kirby/extensions/tags.php?
but what will happen if i update kirby?
is there a way to overwrite the tags.php outside?

however, i found a workaround that works for me (because in this case i have control over the content…)
i use the html-special char for the slash: /
(link: https://www.myurl.de text: https://www.myurl.de)
So the tag-extension doesn’t recognize the text as an url, and won’t shorten.

What I meant is copy the tag into a new file and store in site/tags. That way, your tag will overwrite the default tag and your changes will still be in place if you update Kirby.

Not very comfortable, I’d go for the modified tag.

nice! didn’t know that.
so now i also go with the modified tag and it works fine.