Diffusion extension-PageNameFormula (master)
README.mediawiki
README.mediawiki
== PageNameFormula — a MediaWiki extension ==
PageNameFormula is an extension that provides a page_name_formula that will rename a page based on a formula if any template field within the formula has changed.
The idea comes from Yaron Koren during [https://www.mediawiki.org/wiki/EMWCon_Spring_2017 EMWCon Spring 2017] as a project for the Create Camp day.
I (Mark Hershberger) decided to use the extension as an example for how to build an extension.
== Examples ==
Supppose you have a page with the name <tt>Main_Page</tt> and it includes <tt><nowiki>{{#page_name_formula:{{Main_Page_Name}}}}</nowiki></tt> in the wikitext of the page.
=== first save ===
The first time you save,
# the result of the <tt><nowiki>{{Main_Page_Name}}</nowiki></tt> template would be checked,
# the current name (<tt>Main_Page</tt>) and revision number is stored in the <tt>page_name_mapping</tt> database table, and
# if the template resulted in anything but <tt>Main_Page</tt>, then the page is added to the [https://www.mediawiki.org/wiki/Manual:Job_queue job queue] to be renamed.
=== renaming job ===
When a page renaming job is found in the [https://www.mediawiki.org/wiki/Manual:Job_queue job queue],
# the page is renamed using the [https://doc.wikimedia.org/mediawiki-core/master/php/classMovePage.html MovePage] class,
# the new name (<tt>Main_Page</tt>) and revision number is stored in the <tt>page_name_mapping</tt> database table, and
# unless otherwise specified, a redirect is left in place, and
# any double redirects are fixed, unless <tt>[https://www.mediawiki.org/wiki/Manual:$wgFixDoubleRedirects $wgFixDoubleRedirects]</tt> is false.
=== when page renames are made ===
PageNameFormula is an extension that provides a page_name_formula that will rename a page based on a formula if any template field within the formula has changed.
The idea comes from Yaron Koren during [https://www.mediawiki.org/wiki/EMWCon_Spring_2017 EMWCon Spring 2017] as a project for the Create Camp day.
I (Mark Hershberger) decided to use the extension as an example for how to build an extension.
== Examples ==
Supppose you have a page with the name <tt>Main_Page</tt> and it includes <tt><nowiki>{{#page_name_formula:{{Main_Page_Name}}}}</nowiki></tt> in the wikitext of the page.
=== first save ===
The first time you save,
# the result of the <tt><nowiki>{{Main_Page_Name}}</nowiki></tt> template would be checked,
# the current name (<tt>Main_Page</tt>) and revision number is stored in the <tt>page_name_mapping</tt> database table, and
# if the template resulted in anything but <tt>Main_Page</tt>, then the page is added to the [https://www.mediawiki.org/wiki/Manual:Job_queue job queue] to be renamed.
=== renaming job ===
When a page renaming job is found in the [https://www.mediawiki.org/wiki/Manual:Job_queue job queue],
# the page is renamed using the [https://doc.wikimedia.org/mediawiki-core/master/php/classMovePage.html MovePage] class,
# the new name (<tt>Main_Page</tt>) and revision number is stored in the <tt>page_name_mapping</tt> database table, and
# unless otherwise specified, a redirect is left in place, and
# any double redirects are fixed, unless <tt>[https://www.mediawiki.org/wiki/Manual:$wgFixDoubleRedirects $wgFixDoubleRedirects]</tt> is false.
=== when page renames are made ===
Content licensed under Creative Commons Attribution-ShareAlike (CC BY-SA) 4.0 unless otherwise noted; code licensed under GNU General Public License (GPL) 2.0 or later and other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL · Credits