Board Thread:Support Requests - Getting Technical/@comment-4748628-20140729181943/@comment-4748628-20140811170402

452 wrote: It's a shame the API section parameter only accepts a number, and not the title.

You could use api.php?action=parse&prop=sections&page=(javascript page) to get the list of sections on that page, then a second API call to replace the section matching that person's username. (or add a new section)

edit: that's assuming that a javascript commented section title would be recognised by the API, which I'll go test right now...

edit: Yes, that works: http://community.wikia.com/api.php?action=parse&prop=sections&page=Community_Central:Sandbox&oldid=1317231 - since this gives the section ids, editing those sections using the ids should surely work.

It's still an extra API call for everyone, but if you just do it once and store it for later, it shouldn't be too much extra overhead.

edit: So, the only changes necessary to your existing save function would be to retrieve the section number first, and change the page being edited to be section instead of their javascript page. (and to strip the heading once you load the settings, and to remember prepend the heading when you update it)

Oh, in fact, now I think about it, you're *already* loading that entire page when that user first joins the chat, so there's no need for that API call - you just match their username to the appropriate section, and store the sectionID for when they save it. No extra API call, but a tiny bit of extra logic to find the sectionID.

edit: And since you're just loading a single page, you don't need to use importArticles, you can retrieve it through the api, and pass it through a (custom) validator first before applying. Complicated, but more secure. This should work just fine. Thanks for the ideas!