Jump to content

Topic on Project:Support desk

Don't turn a URL parameter into a link

6
Stefahn (talkcontribs)

In my template I have a {{{parameter|}}} that holds a URL. Now I want to build some button around this URL. Thus the URL should go after href=. The MediaWiki parser disturbs that plan because it turns the URL into a clickable link automatically.

How can I prevent the parser doing this?

PS: With a URL itself I can do

<nowiki>http://url.com</nowiki>

but doing this with the parameter

<nowiki>{{{parameter|}}}</nowiki>

only gives me {{{parameter|}}}

FriedhelmW (talkcontribs)

Can you make the parameter http<nowiki/>://www.example.com?

Stefahn (talkcontribs)

Yes, I think I could do that with some string functions. Are you sure it would work then?

FriedhelmW (talkcontribs)

No, I don't know your templates.

124.180.145.2 (talkcontribs)

You can place the URL in a data attribute, and then it won't be turned into a URL.

<div data-test="http://example.com"></div>
Stefahn (talkcontribs)

I finally found a solution. At least for my case (I work with SemanticMediaWiki). The trick is to add #nowiki to the query.

This is my final code for my button:

<html><a href="</html>{{#show:{{FULLPAGENAME}}|?URL-Property#nowiki}}<html>" target="_blank" class="btn btn-primary">Click here</a></html>