Topic on Project:Support desk

Jump to navigation Jump to search

Cache-safe parser function results?

AyaJulia (talkcontribs)

I was looking through the giant list of extensions and came across Extension:UserMagic which comes very close to some functionality I want for my wiki. I particularly like that it is cache-safe so that no user should see another user's results.

For background, my goal is to add a few settings to the user's preferences and be able to refer to them in article text, such as (examples only) calling a user by a nickname or a drop-down selectable title. It will spoil the effect if Sir Grumpykins starts reading a page that addresses him as Lady Snookums.

I see from that extension's page that it won't function within a parser statement or as a template argument (the magic words are not replaced until after the HTML renders... which is the functionality I want), but I was wondering if it was possible to write something similar that WILL work with a parser function. That is to say, nestle one of these magic words within a {{#switch: __SETTING__ | 0=Foo | 1=Bar | Baz }} and have that switch result NOT cache.

I am about a 2/10 with scripting and programming, and while I learn very quickly with a few code examples, I need a key word or two to get to googling the right thing.

Thank you :)

MarkAHershberger (talkcontribs)

That particular extension will just to a blind search and replace. And, since it does it after all the parsing is done, Your #switch statement will only see "__SETTING__", not what __SETTING__ evaluates to for the user.

Your best bet is probably to do something with Javascript so that changes happen on the User's machine and not on the wiki.