Extension talk:NewArticleTemplates

article and user page templates
i want two custom templates...it works for the article...but how to add USER PAGE namespace? $wgNewArticleTemplatesNamespaces = array(       NS_MAIN                 => 1,        100                     => 1,        102                     => 1,        104                     => 1,        106                     => 1,

NS_USER                => 2, 100                    => 2,        102                     => 2,        104                     => 2,        106                     => 2 ); $wgNewArticleTemplates_PerNamespace = array( NS_MAIN                => "MediaWiki:NewArticleTemplate", NS_USER                => "MediaWiki:NewArticleTemplateUser", );
 * 1) new pages in the main namespace use MediaWiki:NewArticleTemplate:

Preloader for Image/Media Upload
Does the extension work with NS_IMAGE? Thank you for any replying. :-) --Roc michael 22:59, 11 May 2008 (UTC)


 * Oo.et.oO 18:35, 12 August 2008 (UTC):
 * Hi Roc michael,
 * I added:

NS_IMAGE               => 1,
 * to $wgNewArticleTemplatesNamespaces and it works... kinda. when adding an article named "Image:fake_test.jpg" the article used the template specified (in this case : $wgNewArticleTemplatesDefault).   Of course after the article creation it says that no such file exists.


 * However, using the "Upload file" link in the toolbox does not use the template.
 * i might also find that useful if i need users to always put certain markup in the "summary".
 * where would you have the template add the preload markup? in the "summary" box?


 * anyone else have comments on how it would work with upload file?

Download error
Hi Mati, When I tried to download the extension, I will see the following message: Not Found The requested URL /mediawiki/trunk/NewArticleTemplates was not found on this server.


 * Oo.et.oO 18:09, 12 August 2008 (UTC): works for me using both the download http link as well as subversion.

merging of extensions?
I'm the author of the extension described on the subject-page. The See-Also chapter had this added: Perhaps Extension:Preloader, Extension:PreloadManager, Extension:NewArticleTemplates and Extension:Boilerplate should be merged? I skimmed through the other extensions and couldn't find much functionality that is not provided by this extension. If there is functionality that would be "nice to have" in this extension and exists in other extensions, I'm happy to integrate them here - so please post suggestions here. It would also be ok to move it to the MediaWiki SVN, if the MediaWiki-team would like that. Let me know what you think! -- Mati 11:14, 12 October 2008 (UTC)

You have a error in you PHP code
NS_MAIN                => "MediaWiki:NewArticleTemplate", should be        NS_MAIN                 => "MediaWiki:NewArticleTemplate"
 * actually, thats not an error. PHP accepts the coma after the last element in an array. This eases code-maintenance, i.e. consider this:


 * In this code, you can safely add another line at the end and the code still works. If you comment the last line out, again, there is no problem with php. -- Mati 17:33, 12 November 2008 (UTC)

Quick & Dirty patch to add page's name to the template
Thanks for the great extension! I needed a way to put the new page's name into the template text (I'm calling another template that uses in a comparison) and I couldn't see any obvious way to do this, so I made a very quick patch: This can be easily modified to mangle the text in any way you please.

Danielsoneg 01:16, 27 February 2010 (UTC)

How can i make this extension working for Categories ?
Hi,

I'm a newbie in mediaWiki and i need such that extension for customizing special categories like Category:People or Category:Book. is it possible to use this extension for that kind ?

Thank's in advance for any reply

It is working on MW 1.27?
Does anybody if this extension if it working for MW 1.27?

Thanks!


 * It likely worked on MW 1.28 but definitely does not work on MW 1.29. This extension and the Preloader extension both break with error . The best alternative I could find is MultiBoilerplate though that extension does not have per-namespace templates and instead uses a dropdown box listing available boilerplate items by name. Alchemistmatt (talk) 20:30, 24 July 2017 (UTC)


 * It is definitely broken in 1.29. If you're comfortable editing PHP code, I fixed it by replacing the line $text = $rev->getText; with the following two lines in the NewArticleTemplate.php file:

Hope this helps.
 * $content = $rev->getContent( Revision::RAW );
 * $text = ContentHandler::getContentText( $content );

Yes, with my MediaWiki 1.30 the codechange worked. I have requested a Pull

Fatal Error with Link or Transclude
Error: [WvT9tp-H9f-dyfteCeIq0AAAAFE] /index.php?title=Tag:Baloney&action=edit&redlink=1 Error from line 25 of /home/gunsywtx/public_html/extensions/NewArticleTemplate/NewArticleTemplate.php: Call to undefined method Revision::getText

Backtrace:
 * 1) 0 /home/gunsywtx/public_html/extensions/NewArticleTemplate/NewArticleTemplate.php(87): preload(string)
 * 2) 1 /home/gunsywtx/public_html/includes/Hooks.php(177): newArticleTemplates(EditPage, OutputPage)
 * 3) 2 /home/gunsywtx/public_html/includes/Hooks.php(205): Hooks::callHook(string, array, array, NULL)
 * 4) 3 /home/gunsywtx/public_html/includes/EditPage.php(2657): Hooks::run(string, array)
 * 5) 4 /home/gunsywtx/public_html/includes/EditPage.php(689): EditPage->showEditForm
 * 6) 5 /home/gunsywtx/public_html/includes/actions/EditAction.php(60): EditPage->edit
 * 7) 6 /home/gunsywtx/public_html/includes/MediaWiki.php(499): EditAction->show
 * 8) 7 /home/gunsywtx/public_html/includes/MediaWiki.php(293): MediaWiki->performAction(Article, Title)
 * 9) 8 /home/gunsywtx/public_html/includes/MediaWiki.php(851): MediaWiki->performRequest
 * 10) 9 /home/gunsywtx/public_html/includes/MediaWiki.php(523): MediaWiki->main
 * 11) 10 /home/gunsywtx/public_html/index.php(43): MediaWiki->run
 * 12) 11 {main}

Steps: require_once ("$IP/extensions/NewArticleTemplate/NewArticleTemplate.php"); $wgNewArticleTemplatesEnable = true;
 * 1) Install the extension
 * 2) localsettings.php:

$wgNewArticleTemplatesOnSubpages = true;
 * 1) enable on subpages:

$wgNewArticleTemplatesNamespaces = array(       NS_TAG                 => 1);
 * 1) Templates are used in these namespaces:

$wgNewArticleTemplates_PerNamespace = array(       NS_TAG                 => "Template:Tag/Preload", );
 * 1) new pages in the main namespace use MediaWiki:NewArticleTemplate:

Tag:Baloney 
 * 1) new pages in any other namespace defined by $wgNewArticleTemplatesNamespaces use MediaWiki:NewArticleTemplateDefault:
 * 2) $wgNewArticleTemplatesDefault = "MediaWiki:NewArticleTemplateDefault";
 * 1) Place a link or transclude on a page:
 * 1) click the link or transclude

Setting for namespaces ignored in 1.3 & MediaWiki 1.35.4
Unfortunately, this extension seems to fully ignore any settings in  and. Template is applied only to, even if this namespace is missing in. Sample of my code follows:

$wgNewArticleTemplatesNamespaces = [ 3000 => 1 ];
 * 1) Templates are used in these namespaces:

$wgNewArticleTemplatesPerNamespace = array( 3000 => "MediaWiki:NewArticleTemplate", );
 * 1) new pages in the main namespace use MediaWiki:NewArticleTemplates

--Radouch (talk) 08:32, 29 November 2021 (UTC)


 * My very dirty hack (my knowledge of PHP is very limited):
 * In  replace this part:

if (!array_key_exists($namespace, $wgNewArticleTemplatesNamespaces)) { return true; }


 * with

if (!in_array($namespace, $wgNewArticleTemplatesNamespaces, true)) { return true; }


 * and in  define allowed namespaces as

$wgNewArticleTemplatesNamespaces = [NS_MYNAMESPACE1, NS_MYNAMESPACE2,...];
 * --Radouch (talk) 09:09, 29 November 2021 (UTC)