Last modified: 2014-04-21 12:05:06 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T14853, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 12853 - Allow parameter substitution on preload templates
Allow parameter substitution on preload templates
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Page editing (Other open bugs)
unspecified
All All
: Low enhancement with 3 votes (vote)
: ---
Assigned To: Jackmcbarn
: patch, patch-reviewed
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-01-31 19:30 UTC by Tom Humphrey
Modified: 2014-04-21 12:05 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
EditPage.php patch to support preload parameter substitution (1012 bytes, patch)
2008-01-31 19:30 UTC, Tom Humphrey
Details

Description Tom Humphrey 2008-01-31 19:30:10 UTC
Created attachment 4603 [details]
EditPage.php patch to support preload parameter substitution

Preloaded text (text included into new pages using edit links of the form
http://www.mediawiki.org/wiki/example?action=edit&preload=Template:ExamplePreload ) currently cannot use parameter substitution. I think it would be useful to be able to pass parameters for {{{ }}} substitution as part of the &preload parameter.

The attached patch to EditPage.php allows parameters to be provided, ie. support for 
&preload=egtemplate|param=something|one|
which would substitute {{{param}}} and {{{1}}} in egtemplate before creating the new page.

My approach is a bit kludgy and naive, probably the preload page should be properly passed through the parser, but I think could be still be useful.
Comment 1 Bawolff (Brian Wolff) 2012-01-05 13:49:48 UTC
Thanks for the patch.

However, I'm not entirely sure that allowing to specify params via url is something needed. If it is really needed though, we should be using the actual parser to do it, not str_replace'ing the parameters (which is actually much easier now that processing preload text now lives in Parser::getPreloadText )
Comment 2 Bawolff (Brian Wolff) 2012-01-05 13:51:23 UTC
Additionally, if we did that, we'd probably want to process {{{param|foo}}} into foo to be like normal, but then what if someone wants to use preload in order to create a template, and they want their {{{param|foo}}} in the preload source text to be untouched.
Comment 3 Technical 13 2013-05-17 18:18:13 UTC
Was this ability ever implemented?  I would like to create a template that has some parameters passed to it from a linked image. As a note, using pipes in the url would not be ideal if the link was called from [[File:example.jpg|link=url]]  Using a pipe would force users to {{!}} the url.  An alternative might be &preload=Template:Foo^param=bar^one.  See [[User:Technical_13/Templates/NFCC9]] which is just a shell of what I would like to do based on implementation of some kind of ability to pass preload templates arguments. See [[User:Technical 13/SandBox/NFCC]] for full description of what I would like to be able to do with this feature.
Comment 4 Technical 13 2014-03-01 02:28:53 UTC
Bump and add Jackmcbarn to the CC list as he mentioned he could try and write a patch for this on my enwp talk page.
Comment 5 Bawolff (Brian Wolff) 2014-03-01 07:07:54 UTC
>&preload=Template:Foo^param=bar^one

I know pipes are a pain for wiki syntax, but if we're going to do this, I would still prefer we used them instead of using other characters (What if you want to use ^ in a parameter name, what if you have a template named Foo^. Using |'s doesn't cause any more confusion, and its already a reserved character). Users can always use %7C instead of {{!}} in urls.
Comment 6 Gerrit Notification Bot 2014-03-03 14:08:39 UTC
Change 116482 had a related patch set uploaded by Jackmcbarn:
Allow passing parameters to preload

https://gerrit.wikimedia.org/r/116482
Comment 7 Technical 13 2014-03-05 14:39:23 UTC
(In reply to Bawolff (Brian Wolff) from comment #5)
> >&preload=Template:Foo^param=bar^one
> 
> I know pipes are a pain for wiki syntax, but if we're going to do this, I
> would still prefer we used them instead of using other characters (What if
> you want to use ^ in a parameter name, what if you have a template named
> Foo^. Using |'s doesn't cause any more confusion, and its already a reserved
> character). Users can always use %7C instead of {{!}} in urls.

Per [[gerrit:116482]] the syntax will be:
action=edit&preload=Foo&preloadparams[]=first&preloadparams[]=second

Where "first" will be available as $1 and "second" will be available as $2 in the preload template of "Foo" if my understanding is correct.  Does this address your issue/question Brian?
Comment 8 Bawolff (Brian Wolff) 2014-04-07 02:10:49 UTC
(In reply to Technical 13 from comment #7)
> (In reply to Bawolff (Brian Wolff) from comment #5)
> > >&preload=Template:Foo^param=bar^one
> > 
> > I know pipes are a pain for wiki syntax, but if we're going to do this, I
> > would still prefer we used them instead of using other characters (What if
> > you want to use ^ in a parameter name, what if you have a template named
> > Foo^. Using |'s doesn't cause any more confusion, and its already a reserved
> > character). Users can always use %7C instead of {{!}} in urls.
> 
> Per [[gerrit:116482]] the syntax will be:
> action=edit&preload=Foo&preloadparams[]=first&preloadparams[]=second
> 
> Where "first" will be available as $1 and "second" will be available as $2
> in the preload template of "Foo" if my understanding is correct.  Does this
> address your issue/question Brian?

I'm fine with that syntax. I object to suddenly treating ^ as magic divider.

---

Anyways, patch merged. As has been stated above you can do things like action=edit&preload=Foo&preloadparams[]=first&preloadparams[]=second and have $1 replaced with first, $2 replaced with second, etc. $* will output all parameters, plus a colon (Consider the $* a side effect, which would probably not change, but we make no guarantees that it won't some far off day in the future). It should probably be available on Wikipedia by April 17.
Comment 9 Gerrit Notification Bot 2014-04-07 02:13:19 UTC
Change 116482 merged by Brian Wolff:
Allow passing parameters to preload

https://gerrit.wikimedia.org/r/116482

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links