Pergunta

I'm creating template on a personal wiki and I want some of the links to have custom attributes (e.g. rel, class, etc.).

Using HTML Syntax

I tried to put it as HTML code, but it's then escaped:

<a href="#{{{atelier-id|ex:atelier-id}}}" class="pilcrow">¶</a>
<a href="{{{auteur_url|ex:giroll.org/}}}" rel="author">{{{auteur|ex:auteur}}}</a>

Using Wiki Syntax

Then I tried using a wiki syntax, but still no good

[[#{{{atelier-id|ex:atelier-id}}}"|¶|pilcrow]]

Question

This seems trivial but I don't find any information on Help:Links page.

So how should I do to add extra attributes to my links ?

Foi útil?

Solução

MediaWiki has no built in way to add link attributes, however there are at least two extensions that provide that functionality. You could try:

Outras dicas

Have you tried creating a class in Mediawiki:Common.css that adds the desired attributes to <a> tags? Mediawiki doesn't allow raw anchor tags in the code, but wikilinks are still converted to anchor tags when the page is rendered. IF you do something like this:

.class a:link,
.class a:visited,
.class a:active,
.class a:hover {
    css: some css;
}

then you can wrap your link in the desired class, e.g. <span class="class">[[link]]</span>, and have the attributes applied automatically. You should be able to invoke javascript in this way as well.

You can solve this by wrapping your links in a span with an id and adding a CSS selector for that id's a elements

In your article:

<span id="link-wrapper">[[YourLink]]</span>

In your CSS:

#link-wrapper a
{
    background-color: #ffffff;
}

I don't think I can imagine a situation where that won't suffice. There's plenty of other workarounds I can think of, let me know if this one won't do.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top