Hey,
I'm looking for a way to change values passed to a parser function when it's executed. This would be to change addresses in the parser functions of the Maps extension into coordinates, so the geocoding doesn't need to happen every time the parser function is executed.
Example:
You enter: {{display_map:foobar}}
Then save the page, and when you edit, it shows: {{display_map:93.42, 12.34}}
What hook would be suited for such a thing?
Cheers
-- Jeroen De Dauw * http://blog.bn2vs.com * http://wiki.bn2vs.com Don't panic. Don't be evil. 50 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65! --
On 21 August 2010 13:46, Jeroen De Dauw jeroendedauw@gmail.com wrote:
Example:
You enter: {{display_map:foobar}}
Then save the page, and when you edit, it shows: {{display_map:93.42, 12.34}}
What hook would be suited for such a thing?
None of them. Either store it out-of-band, or require users to subst: - it's not possible to do anything else in a consistent manner. Consider the behaviour of a template containing: {{display_map: {{{1}}} }}.
Conrad
________________________________________
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Jeroen De Dauw wrote:
Hey,
I'm looking for a way to change values passed to a parser function when it's executed. This would be to change addresses in the parser functions of the Maps extension into coordinates, so the geocoding doesn't need to happen every time the parser function is executed.
Example:
You enter: {{display_map:foobar}}
Then save the page, and when you edit, it shows: {{display_map:93.42, 12.34}}
What hook would be suited for such a thing?
Cheers
-- Jeroen De Dauw
There's no hook in the preSaveTransform() And it's much saner this way.
Your use case has several problems: *You are saving something very different than what the user has wrote. *What if the geocoding is later improved and foobar now maps to 93.37, 12.338 ? *The user misspelt foobar as foobaz, which happens to be in 7.21, 148.4 How would other users /easily) detect that mistake? *foobar doesn't exist now and isn't translated. It gets added later, and it's substituted on the next page save, which may be totally unrelated. *It's not obvious on [[foobar]] that the map is pointing to the correct coordinates (the user could have written foobar, or a wrong coord).
You want to not do the geocoding on each parserfunction call. Great, cache it in $wgMemc and recover from there when needed.
wikitech-l@lists.wikimedia.org