Extension talk:Sort2
Discussion goes here
Contents |
[edit] Option style=""
I thought about implementing the style option to be restricted to the list style types valid for ordered lists. To be honest, I was too lazy and I chose to pass any style through.
If this is considered to be too threatening and if there's consensus I am willing to implement the restriction.
I just need your feedback on this.
[edit] Bugs
Hey,
Before the Sort2 function you created I had a list like the following:
But when I changed it for the sort2 my link to my doc did not work anymore:
<Sort2> Software Configurations Permission -> Disconnects Unable to browse </sort2>
You might want to see if you could include this functionally
Thanks, Justin
Special characters like colons (:), asterisks (*), and hashes (#) are removed even if they are not serving as list item markers. This means that, for instance, sorting a list that includes any links with namespaces or external (http://) links will break the links.
CarLuva 21:41, 21 October 2009 (UTC)
[edit] Suggestions
Hi. Is it possible to sort links? SORT2 is removing ":" ? Is this right? Anyway thank you for your extension. --Micc 20:55, 1 March 2007 (UTC)
[edit] Used @
[edit] Not working with links
Useful extension. But breaks on lists with links. any fixes?
- We use the extension at Stargate Wiki. We had no problems with links. Example: Template:Erd-Objekt.
- We've tried to get it to work with in-page links; but since it removes the '#' sign (and other chars) these links cannot be sorted. It also can't deal with parameters sent into a template, e.g. <sort2>{{{myparams}}}</sort2>, --Callum Wilson 10:45, 23 August 2010 (UTC)
[edit] How to add first letter?
How to create list for example?
A
- AMD
- argument
B
- ball
- BMW
[edit] Modifications
I must admit that I'm still green when it comes to PHP. I've created the following modifications to extend the functionality of this extension. The mods are ugly and I can't be 100% they won't break something else.
In order to add URLs modify the function stripWikiListTokens to the following:
function stripWikiListTokens( $text ) { $text = trim(str_replace( 'http:', 'http{colon}', $text)); $find = array( '*', '#', ':'); $text = trim(str_replace( $find, '', $text )); return trim(str_replace( 'http{colon}', 'http:', $text )); }
What we're doing is going through out Sort2 block and looking for http: and temporarily replacing it with http{colon}. Then we go through the Sort2 block again removing all the MediaWiki specific list tags. Finally we go through the Sort2 block one last time replacing http{colon} with http:.
If you are alphabetizing a list of links in standard [url display] format Sort2 will alphabetize based on the URL. So a URL of [http://www.google.com Google] will come AFTER [http://google.com Google]. Both links are evaluated on the first letter following the http://. Therefore Sort2 sorts using the W in the former and the G in the later.
This may sound odd but I didn't like how the 'br' type looked. Especially considering that paragraphs are separated using '<p>' tags instead. I added an additional type to support this. In order to implement add the following:
In function loadSettings look for this line:
if( $c == 'ol' || $c == 'ul' || $c == 'dl' || $c == 'inline' || $c == "br")
and replace it with the following line to make 'p' a valid 'type':
if( $c == 'ol' || $c == 'ul' || $c == 'dl' || $c == 'inline' || $c == "br" || $c == "p")
Finally we need to handle 'p' types. In the function makeList add the following case to the switch statement:
case ("p"): $starttoken = ""; $endtoken = ""; $listtoken = "<p>"; $endlisttoken = "</p>"; $this->separator = ""; break;
Then just use Sort2 as you normally would using 'p' as a type, <sort2 type="p">
BlueSuede 21:21, 8 December 2011 (UTC)