Search code examples
mediawikimediawiki-templatessemantic-mediawiki

Split a string in semantic MediaWiki


I want to add a link using existing string in in my wiki page. This string will be appended to a url to form a complete URL.

This string consists of many words, for example "Crisis Management in International Computing"

I want to split by empty space " " then construct this string: "Crisis+Management+in+International+Computing"

Here is the String variable I have in my wiki page:

{{SUBJECTPAGENAME}}

Note: I have to check first if the string consists of more than one word, as if the string is just one word like this "Crisis" I won't perform split function.

I searched the web and did not find clear semantic to us in order to perform this issue.

Anyone experienced such a matter?


Solution

  • I would recommend you to go for a custom parser function.

    Or as a hack, try splitting the string using the arraymaptemplate parser functions coming as part of Semantic Forms.

    URL : arraymaptemplate parser function.

    You can use an intro template to create the link and use array template to split and add the words to the intro template.

    I have not tried it with delimiter character as space, but from the documentation, seems, it should be working using the html encoding for space.