Template:TitleParts/Splice
--><!-- start code -->{{#ifeq: {{{4|a}}} | {{{4|b}}}<!-- -->|{{Template:TitleParts/Splice/1|{{{1|}}}|{{Template:TitleParts/SizeOf|{{{1|}}}}}|{{{2|0}}}|{{{3|0}}}|{{{4|}}}<!--end template call-->}}<!-- -->|{{Template:TitleParts/Splice/1|{{{1|}}}|{{Template:TitleParts/SizeOf|{{{1|}}}}}|{{{2|0}}}|{{{3|0}}}<!--end template call-->}}<!-- -->}}<!-- end code
-->This is a helper template used for splicing a string using the #titleparts syntax in much the same way PHP's array_splice works.
The first parameter represents the array.
The second parameter represents the splice offset index to start from. (if negative counts in reverse from the last element)
The third parameter represents the number of elements to remove (if negative leaves that many elements before the last element).
And the optional fourth parameter will replace the removed elements with the array you provide as the fourth parameter.
Example
Result | Source Code |
A-D/E/F/G | {{Template:TitleParts/Splice|A/B/C/D/E/F/G|0|4|A-D}} |
A/B/C/D/E | {{Template:TitleParts/Splice|A/B/C/D/E/F/G|-2|2}} |
A/Hi/There/C/D/E/F/G | {{Template:TitleParts/Splice|A/B/C/D/E/F/G|1|1|Hi/There}} |
A/B/C/G | {{Template:TitleParts/Splice|A/B/C/D/E/F/G|3|-1}} |
before/A/B/C/D/E/F/G | {{Template:TitleParts/Splice|A/B/C/D/E/F/G|0|0|before}} |
Limitations
Do note that data expressed with #titleparts is very limited. For a number of reasons:
- The data has a 255 character limit since #titleparts was designed to work with your address bar.
- There can only be 25 slashes in the string. Any more will be truncated.
- The first character of the string will be changed to uppercase.
More Info
For more information on #titleparts, check the "ParserFunctions" section of your MediaWiki manual.