Help:Titleparts

From SacredWiki
Jump to navigation Jump to search

Parser function #titleparts produces a subsequence of a sequence of up to 25 strings separated by slashes (if there are more than 24 slashes the excess slashes are treated as plain text belonging to the 25th string). Since it was designed for application to a page title the total string has to be a valid page title, otherwise this total string is returned. This means that the total amount of memory including that for the slashes is limited to 255 bytes and that some characters including rectangular brackets are not allowed. Also, on retrieval some changes to the canonical form occur; e.g., the first character of the first string in the original sequence is usually capitalized, see below.

{{#titleparts: total string | m | n }} returns m strings starting from the nth.

For m = 0 (the default) all strings from the nth are returned. A negative value -m indicates that m strings should be removed from the right. The default of n is 1. For n = 0 the result is the same. A negative value -n indicates that the leftmost string in the result should be the nth string from the right.

  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j}}" → "A/b/c/d/e/f/g/h/i/j" [1]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|4}}" → "A/b/c/d" [2]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j||2}}" gives "b/c/d/e/f/g/h/i/j" [3]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|0|2}}" gives "b/c/d/e/f/g/h/i/j" [4]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|4|2}}" gives "b/c/d/e" [5]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|9|2}}" gives "b/c/d/e/f/g/h/i/j" [6]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|10|2}}" gives "b/c/d/e/f/g/h/i/j" [7]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|4|11}}" gives "" [8]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4}}" → "A/b/c/d/e/f" [9]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4|5}}" gives "e/f" [10]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4|6}}" gives "f" [11]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4|7}}" gives "" [12]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4|8}}" gives "" [13]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j||-4}}" gives "g/h/i/j" [14]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|3|-4}}" gives "g/h/i" [15]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|4|-4}}" gives "g/h/i/j" [16]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|5|-4}}" gives "g/h/i/j" [17]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-2|-4}}" gives "g/h" [18]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j|-4|-2}}" gives "" [19]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z|1|1}}" gives "a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z" [20]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x|1|1}}" gives "A" [21]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x|1|25}}" gives "y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x" [22]
  • "{{#titleparts:a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x|1|26}}" gives "" [23]
  • "{{#titleparts:éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/|1|1}}" gives "éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/éééééé/" [24]

Special considerations

Slashes are not allowed in the strings, except in the 25th string and in strings starting with ./ (see below), since they are used as separator. Unlike the pipes the slashes need not be explicit in the wikitext, they can be produced by expansion. This also means that the slash cannot be part of a string even with a technique like {{!}}.

Some special results:

  • "{{#titleparts:a / c|1|1}}" gives "A " [25] (a becomes A, as already seen above; space is preserved)
  • "{{#titleparts:a / c|1|2}}" gives " c" [26] (space is preserved)
  • "{{#titleparts:talk:b/c|1|1}}" gives "Talk:B" [27] (t and b are capitalized
    • compare: "{{#titleparts:tlk:b/c|1|1}}" gives "Tlk:b" [28] (t is capitalized
  • "{{#titleparts:w:a/c|1|1}}" gives "W:a" [29] (neither t nor a is capitalized)
  • "{{#titleparts:a#b/c|1|1}}" gives "A" [30] (returns the substring before #)
  • "{{#titleparts::b/c|1|1}}" gives "B" [31] (leading colon is removed)
  • "{{#titleparts:a_b/c|1|1}}" gives "A b" [32] (underscore is converted to space)
  • Template:Xpd5o5c multiple consecutive spaces are converted to a single one)
  • Template:Xpd5o5c multiple consecutive underscores are converted to a single space)

Not a valid page name:

  • "{{#titleparts:./c|1|1}}" gives "./c" [33]
  • "{{#titleparts:./b/c|1|1}}" gives "./b/c" [34]
    • compare "{{#titleparts:a./b/c|1|1}}" gives "A." [35]

The changes in strings beyond the first are more limited:

  • "{{#titleparts:a/c_d|1|2}}" gives "c d" [36] (underscore is converted to space)
  • b c multiple consecutive spaces are converted to a single one)
  • b c multiple consecutive underscores are converted to a single space)

See also

<references group=""></references>

Links to other help pages

Help contents
Meta · Wikinews · Wikipedia · Wikiquote · Wiktionary · Commons: · mw: · b: · s: · mw:Manual · Google
Versions of this help page (for other languages see further)
Meta · Wikinews · Wikipediahttp://en.wikipedia.org/index.php/Help:Titleparts · Wikiquote · Wiktionary
What links here on Meta or from Meta · Wikipedia · MediaWiki
Reading
Go · Search · Stop words · Namespace · Page name · Section · Backlinks · Redirect · Category · Image page · Special pages · Printable version
Tracking changes
Recent changes (enhanced) | Related changes · Watching pages · Diff · Page history · Edit summary · User contributions · Minor edit · Patrolled edit
Logging in and preferences
Logging in · Preferences · User style
Editing
Starting a new page · Advanced editing · Editing FAQ · Edit toolbar · Export · Import · Shortcuts · Edit conflict · Page size
Referencing
Links · URLs · Piped links · Interwiki linking · Footnotes
Style and formatting
Wikitext examples · CSS · Reference card · HTML in wikitext · Formula · List · Table · Sorting · Colors · Images and file uploads
Fixing mistakes
Show preview · Testing · Reverting edits
Advanced functioning
Expansion · Template · Advanced templates · Parser function · Parameter default · Variable · System message · Substitution · Array · Calculation · Embed page
Others
Special characters · Renaming (moving) a page · Talk page · Signatures · Sandbox · Legal issues for editors