Topic on Project:Support desk

Numbered alternative texts in links

4
Blumenfuchs (talkcontribs)

Hey,

I´d like to know if it is possible to have a numbered list of links using # ?

Just like

[[Link|#Linkwithnumber1]]

[[Link|#Linkwithnumber2]]

I just want to get the same result as if the links would be an ordered list.

137.147.1.122 (talkcontribs)
# [[Link1]]
# [[Link2]]
Blumenfuchs (talkcontribs)

Thank you, but I realized I described my problem wrong. If I get the numbers by using # in front of the link (but also by using <ol>...</ol>) the numbers aren´t bold and blue, which is why I´d like them to be part of the link.

121.214.7.243 (talkcontribs)

This can be done with CSS counters. Add this to MediaWiki:Common.css:

.linked-nums {
    counter-reset: linked-nums;
    list-style: none;
    position: relative;
}

.linked-nums > li > a:first-child:before {
    content: counter(linked-nums) ".\00a0";
    counter-increment: linked-nums;
    left: -3.2em;
    position: absolute;
    text-align: right;
    text-decoration: inherit;
    width: 3.2em;
}

This assumes you use the default MediaWiki styling for ordered lists, otherwise you may need to tweak the left and width values. If your list items only contain a link, you can remove the :first-child.

Then you can use the linked-nums class on any ordered list to move the numbers to inside the links. Example:

<ol class="linked-nums">
    <li>[[Link|Linkwithnumber1]]
    <li>[[Link|Linkwithnumber2]]
</ol>