Extension talk:BoilerplateSelection

How the keywords work?
So I take it that the array says that if the article has that keyword in it, anywhere, then it will then load up the named boiler plate? So, if the key word is "Sand", then a page with the title "Sandbox", "Red Sand" etc will load up that boiler plate? --Dr DBW 03:44, 23 August 2007 (UTC)


 * I have just updated the process with a small change. I have added a flag during forEach loop which will cause the process to ignore multiple hits.  I have put an example in the usage section.  But basically if the first elements of your array contains 'this', 'that' and 'this other' then the process will first look for 'this' in the title.  If it finds it then it will use the associated template.  Let's say your title is This Doc about That.  Before I added the change it would look for 'this' and find it.  But then it would look for 'that' and find it also.  It would use the second instance.  Now, with the flag, it will look for 'this' find it and use its template ignoring any other hit.  Does this clear it up?  Remember that if it doesn't find any hit it will attempt to find a template called 'Boilerplate' and use it.  --Dtsig 14:00, 23 August 2007 (UTC)


 * Certainly does and I think should do what I want it to. Want it to use a particular template on talk pages, and none on normal article pages. --Dr DBW 03:24, 27 August 2007 (UTC)

Possible to extend to use a particular plate for a talk page based on what category the article is in?
Your extension should do what I want it to, as noted above. :-) However, just trying to push things further ;-) and make things neater. Any idea how difficult it would be to extend it to so that when people edit a talk page, they are provided with a particular plate based on the category that article page is part of? That make sense? --Dr DBW 03:28, 27 August 2007 (UTC)

Hmm, Not Working
Just installed this and it doesn't appear to be working. I have a page titled Boilerplate and have the following in LocalSettings.php. When I go to the page titled Sand get the normal warning that contains nothing, search for title or edit. When you edit, it then actually has the text for the message, not a blank box as you normally get, and definitely not the Boilerplate document. Any ideas? --Dr DBW 02:39, 30 August 2007 (UTC)

Sorry been away --Dtsig 18:52, 29 October 2007 (UTC)
Sorry have been away and missed these errors. We use this extension daily and so *know* it works. Can you walk through the process and let me know what is not working. Here is what our current setup in localsettings.php looks like # dsig  12jun07 rights overwritten - user cannot move page require_once("extensions/boilerplateselection.php"); global $wgBoilerPlateAry; $wgBoilerPlateAry = array(		'Copy.Books' => 'CopyBooks',		'Technical Analysis' => 'TechnicalDesign',		'Scope' => 'Scope',		'Data Analysis' => 'DataAnalysis');

When a page is created that doesn't fall into any of the bits above it will automatically read 'boilerplate' and use it as the default. What is your setting and what happens for you? I **assume** that you have a page called boilerplate created in Templates and that any other "boilerplate" page exists in Tempaltes.


 * Thanks for the reply :-) However, found another solution that suits us.  We are using the links with   to get to preload something to a page. -- Dr DBW  |  talk  01:25, 30 October 2007 (UTC)

This thing doesnt work
Same problem as above.

--Dtsig 18:45, 19 December 2007 (UTC)
Did you get this worked out? I never got a notice of you comment .. not sure why

The template loads all wrong.
I am loading my template and it looks hideous! Nothing comes out right. I was looking at why this may be happening and I was wondering if this extension works alright with FCKEditor? It almost seems as though it is trying to load directly into the textbox which is set to load in preview mode instead of wikitext. SO that when the wikitext box is selected it mangles it up even more. Does it normally work with FCKEditor or is there someway to make it work? - Kelsey

--Dtsig 18:43, 19 December 2007 (UTC)
Yep .. it is simply set to go to the textbox. I imagine it could go to 'wikitext' but would have to be parsed at a different location

Fixed "notice" warning in Special:Version"
This extension was making our Version page not list the extension in its lists and also complain with

Notice: Undefined offset: 1 in C:\Inetpub\wwwroot\kb\includes\SpecialVersion.php on line 267

so I changed the line

$wgHooks['EditPage::showEditForm:initial'][] = array('boilerplateselection');

to

$wgHooks['EditPage::showEditForm:initial'][] = 'boilerplateselection';

and now all is well. I haven't tested much more than the Version page and simply loading up a boilerplate template when creating a new page, but it looks good so far.

Extension not working on namespace
I have installed the extension, and it works fine as long as the article is in the main namespace, what I wanted to do was on our company wiki we have a namespace called Customers:

I then allow other people using the inputbox extension to create a new customer which would be Customer:New Customer which preloads the customer information template, the customer information template contains links to create the cutomers information area using the following syntax [Customer:/subpage]

I have tested this in the help namespace and the same problem occurs, the sub-pages work as well in the main article namespace, the only problem seems to be with the custom namespace

Any and all guidence greatly appreciated - sorry not a logged in user, for some reason the Chinese wish to block the MediaWiki site so I have to surf here using a proxy

MarkBolton

OK figured it out there is a line in the extension that reads

&& $editpage->mArticle->mTitle->mNamespace==0

Change the Namespace number to the required namespace and it works, now to try to impliment it for multiple namespaces

MarkBolton

Another possible workaround?
I, too, wanted to use this extension for namespaces. I commented out the conditional that Mark mentioned above and added the following line (prefixed with a '+') to retrieve the full page name, complete with namespace:

// get the title for the current article + $articleTitleWithNS = $editpage->mArticle->mTitle->getPrefixedText; $articleTitle = $editpage->mArticle->mTitle->getText;

I then modified the regular expression matching to include the namespace + title string:

if ( eregi($bpKey, $articleTitle. '|' . $articleTitleWithNS) ) {

In, I then include the namespace in the key to be matched:

$wgBoilerPlateAry = array( 'Foo:Sample' => 'FooSampleStub',  'Bar' => 'BarStub' );

Limited testing has so far proved successful. YMMV.

--Krohnk 14:55, 29 July 2008 (UTC)

Problems with brackets
Getting an error in line 71 :-

if ( eregi($bpKey, $articleTitle) ) {

Message is :- Error REG_EPAREN in extensions/BoilerplateSelection.php on line 71

I suspect this is because I have a '(' in the array in local settings:-

$wgBoilerPlateAry = array('Form (' => 'new_form')

I've solved it by escaping the '(' in the array so it now looks like

$wgBoilerPlateAry = array('Form \(' => 'new_form');

and this works, but it would be better done in the BoilerplateSelection.php code but it's out of my league

Tarlachmoorhouse 09:26, 10 June 2008 (UTC)

interference with CreateArticle
if both BoilerplateSelection and CreateArticle are active, bs will create empty pages even if preload was specified in ca; even worse, in mw 1.15 it will include a 'not found' string into the empty page. However, if the lines

$editpage->textbox1=$preload_text; $editpage->textbox2=$preload_text;

are modified into

if ($flgFound) { # only include if something matches!! $editpage->textbox1=$preload_text; $editpage->textbox2=$preload_text; }

it works. this should probably be modified in the source. --Sarefo 19:57, 6 January 2010 (UTC)

Name Space specific rules
I've made changes to this extension to allow for name space specific rules, if anyone is interested? function boilerplateselection($editpage) { ...   if (!$editpage->preview     	&& !$editpage->mArticle->mContentLoaded     	&& ($editpage->mArticle->mTitle->mNamespace==0 || $editpage->mArticle->mTitle->mNamespace>=100)) {//only check the default name space and custom namespaces ...			foreach ($wgBoilerPlateAry as $bpKey => $bpValue) { if ( !$flgFound ) { if ( eregi($bpKey, $editpage->mArticle->mTitle->mNamespace.':'.$articleTitle)) {//updated $boilerPlateArticle = $bpValue; $flgFound = true; break; }				}   ...    return true; }

After making these changes then you can do the following in the LocalSettings.php file: define("NS_MY_NAMESPACE", 100); $wgExtraNamespaces[NS_MY_NAMESPACE] = "SBU"; $wgBoilerPlateAry = array(   NS_MY_NAMESPACE.':.*' => 'My_Namespace_(default)' );

My only issue with my own code is that I don't know how to use the namespace name instead of it's index number, which is entirely due to my lack of the mediawiki API. Any suggestions?

--Ceaser 15:53, 4 February 2010 (UTC)

error code
BoilerplateSelection works OK but getting error message Deprecated: Function eregi is deprecated in E:\iwpserver\htdocs\mediawiki\extensions\Boilerplateselection\Boilerplateselection.php on line 72 global $wgBoilerPlateAry; $wgBoilerPlateAry = array('Cub' => 'Cub','Joey' => 'Joey', 'Leader' => 'Leader'); if ( eregi($bpKey, $editpage->mArticle->mTitle->mNamespace.':'.$articleTitle)) {//updated $boilerPlateArticle = $bpValue; $flgFound = true; break;

This can be solver by replacing eregi by preg_match with the /i parameter--Mickbravo (talk) 10:32, 25 September 2016 (UTC)

not loading the template
After doing the eregi fix, I had to edit the source code to make the plugin work and remplace this: if (!$editpage->preview    	&& !$editpage->mArticle->mContentLoaded     	&& $editpage->mArticle->mTitle->mNamespace==0) {

By this: if (!$editpage->preview    	&& $editpage->mArticle->mRevision == NULL     	&& $editpage->mArticle->mTitle->mNamespace==0) { because $editpage->mArticle->mContentLoaded is always TRUE even for empty pages.

I see many negative comments on this page
So, is it a secure extension, and does it work?