Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get wiki template's content?

Does anybody know how to get access to the template's body inside the page?

I'm familiar with the API that returns the list of ALL templates that exist on the page, but how I can get access to the template's body? Is there any API for this? For now I see only one possible way... parse it manually. Am I wrong?

like image 369
Mr. Pumpkin Avatar asked Sep 14 '11 13:09

Mr. Pumpkin


2 Answers

You can use the expandtemplates API call, or the rvexpandtemplates parameter for the revisions API call.

like image 75
Tgr Avatar answered Nov 19 '22 20:11

Tgr


This is an old question, but it helped me figure out how to fetch a mediawiki page with template macros expanded. Very useful if you are doing a conversion.

<MW_BASEURL>/api.php?action=query&prop=revisions
   &titles=<url_encoded_page_title>&format=xml&rvprop=content&rvexpandtemplates

I am parsing the xml returned from this query to get the expanded page.

like image 45
russtman Avatar answered Nov 19 '22 22:11

russtman