Open main menu

UESPWiki β

UESPWiki:Archive/CP StringFunctions

< UESPWiki:Community Portal
This is an archive of past UESPWiki:Community Portal discussions. Do not edit the contents of this page, except for maintenance such as updating links.

StringFunctions

Short version: Would it be possible to introduce the StringFunctions extension?

Long version: I've been trying to figure out how to create a template that would allow anchors to be easily created within pages; this would make it easier to link, for example, to the specific entry in a table. I've been playing with it on the oblivion spells page, so for example you can create a link directly to a specific spell. The only problem is the template I've been using, Template:Oblivion Spell Name, requires you to type in each spell's name twice: i.e., both as "Encumbering Touch" and "Encumbering_Touch" (which means when you're updating the tables it's really easy to accidentally mess things up). What I'd like to do is have a template that does that conversion itself. At the wikimedia page, there is a discussion of a StringFunctions extension, which introduces a "urlencode" function, that does exactly that. But it seems like that extension is not enabled on our site. Would it be possible to add that extension? Or do any wiki-savvy people out there know another way to achieve what I'm trying to do?--Nephele 13:11, 9 July 2006 (EDT)

Heh, I have a list of extensions I want as well. CharInsert, InputBox, ParserFunctions, and the latest MediaWiki update would all make me very happy. --Aristeo 18:36, 9 July 2006 (EDT)
I already found a workaround for this. Check out how Oblivion:Ingredients and Oblivion:Alchemy Effects work together. The templates they call are maybe a little too specialised (they can't be easily used for other page match-ups), but they do work. GarrettTalk 18:49, 10 July 2006 (EDT)
I've definitely spent time looking at the templates on the Ingredients and Alchemy Effects pages: that's where I first learned how to even create a link to an entry in a table. But those templates again require the user to type in the names twice, i.e. Bergamot Seeds{{Oblivion Ingredients Entry|Bergamot_Seeds}}, once with spaces changed to underscores. A couple of weeks ago alot of the links on the Ingredients page were broken, because the some of the names in the templates didn't contain underscores, presumably because users who were updating the tables didn't understand why the underscores were there (me included until recently). What I was trying to figure out was a way to create a smarter template that can take the name entered just once: kind of like the ==Section title== tags do.--Nephele 21:05, 10 July 2006 (EDT)
OK, try this: <span id="{{localurl:{{{whateverkeyword}}}}}"></span>. I'm not sure if this will work, but it's the best I can throw together at the moment. I'll look into it further sometime soonish. GarrettTalk 23:56, 10 July 2006 (EDT)
OK, that didn't work... hmmm... well, another way is to use a hidden header ( <div style="overflow: auto; height: 1px">===={{{1}}}====</div> ), but the problem there is it will appear on the TOC (if any) with whatever name you've given it, and spans won't work so there's a forced line break. Anyway, see if that fits your purpose. GarrettTalk 04:36, 15 July 2006 (EDT)

Update: I've added the StringFunctions, CharInsert, InputBox, and ParserFunctions extensions as requested. Make sure to test them to ensure they are working correctly and let me know if there are any problems. DaveH 18:32, 30 July 2006 (EDT)

Actually, for the immediate application I was interested in here, now the functions don't seem to be necessary: the wiki upgrade has made it so that any name used as a span id is automatically urlencoded. But I'm only just starting to see what all is possible now with templates, so I'm sure I'll be testing those extensions soon --Nephele 22:35, 30 July 2006 (EDT)