Module:utilities: Difference between revisions
No edit summary |
Try hard to avoid empty sort key, which causes categories to be displayed as raw text; fall back to pagename if necessary. |
||
| Line 146: | Line 146: | ||
-- Generate the automatic sort key. | -- Generate the automatic sort key. | ||
local auto = lang:makeSortKey(sort_base or pagename or get_pagename(), sc) | local auto = lang:makeSortKey(sort_base or pagename or get_pagename(), sc) | ||
-- Use the page defaultsort if necessary. | -- Use the page defaultsort if necessary. Try hard to avoid empty sort key, which causes categories to be | ||
-- displayed as raw text; fall back to pagename if necessary. | |||
if not auto or auto == "" then | if not auto or auto == "" then | ||
auto = defaultsort or get_defaultsort() | auto = defaultsort or get_defaultsort() | ||
end | |||
if not auto or auto == "" then | |||
auto = sort_base | |||
end | |||
if not auto or auto == "" then | |||
auto = pagename or get_pagename() | |||
end | end | ||
-- If not sort key specified, use the automatic one. | -- If not sort key specified, use the automatic one. | ||
| Line 305: | Line 312: | ||
return "<ul class=\"catfix\" data-anchor=\"" .. | return "<ul class=\"catfix\" data-anchor=\"" .. | ||
anchor_encode(lang:getFullName()) .. "\">" .. | anchor_encode(lang:getFullName()) .. "\">" .. | ||
tag_text("", lang, sc) .. "</ul>" | tag_text("", lang, sc) .. "</ul>" .. | ||
format_categories("Pages using catfix", nil, nil, nil, true) | |||
end | end | ||