Hello,
I'm new to MediaWiki (and PHP), and need a little help. First off - a big thank you to Brion and everybody that works on MediaWiki. It is a tremendously easy to use and useful system.
I have a similar request to Aviram, and could use a pointer or two. I want to be able to populate a page with different template texts. I am thinking that a nice, small, start would be to add some buttons to the edit page screen. Just like the buttons add text to a page for bold text, an embedded image, or media file link, I would like to add a button that plops in some template text.
I'm using MediaWiki 1.4rc1. I see in EditPage.php a function called getEditToolbar(), that then has an array of toolbar buttons.
Question 1: would this be the best/correct place to add my template text?
I copied one array(...) section and added it near the end, substituting in my personalization as appropriate. It does plop in the template text - so far, so good. :-) I just don't know if there is somewhere else I should be making these modifications, than in EditPage.php
So now, I can add three or four buttons to correspond with the three or four standard templates my different pages will use.
The next challenge is to take this to the next level....
Question 2: Is it possible to get those edit buttons to prompt the user for data? It would be nice - but I would need some guidance where to learn how to do this.
Thank you for your time, and any help you can give me.
David Gerisch, Systems Development Specialist A.C.S. / Tulare County Information Technology degerisch@co.tulare.ca.us
mediawiki-l-request@Wikimedia.org Friday, March 11, 2005 5:17 AM
Date: Thu, 10 Mar 2005 10:01:16 -0800 From: Jan Steinman Jan@Bytesmiths.com Subject: Re: [Mediawiki-l] Forcing template To: MediaWiki announcements and site admin list mediawiki-l@Wikimedia.org Message-ID: d2445e084148467c21f4f85d3eaa6363@Bytesmiths.com Content-Type: text/plain; charset=US-ASCII; format=flowed
On 10 Mar 2005, at 00:54, Aviram Jenik wrote:
I would like to force (or at least make it the default behavior) for
new pages to appear in a certain layout. Basically, the idea is that instead of
filling out an empty page... they would only have to 'fill in the blanks'.
I think I know what Brion will say about this... :-)
If you imagine a continuum between rigid structure on the right, and totally free-form on the left, then Wikis in general fall very much to
the left.
It isn't that you absolutely could not do such a thing, but it does run
counter to the Wiki Way, which is anarchic and non-authoritarian.
An easier path than having fill-in fields would be to have some pre-installed text. I'm just guessing, but you might be able to do that
in Article.php in the constructor. That way, your users would not have
to face "blank page shock" and you could "suggest" a typical article layout. A tidy implementation that they might consider rolling in might
include an instantiation hook that could would cause a call to an extension for providing new page text.
Is something like this possible?
Just because something is possible, doesn't mean it's a good idea!
:::: Terrorism is the best political weapon, for nothing drives people
harder than a fear of sudden death. -- Adolf Hitler :::: Jan Steinman http://www.Bytesmiths.com
On 11 Mar 2005, at 09:54, David Gerisch wrote:
I want to be able to populate a page with different template texts.
If you mean the same URL with different texts at different times, you're gonna run up against the "cache problem".
Essentially, it is pretty deeply wired into MediaWiki that pages do not change unless edited. You can search the archives for "cache" and see that some are discussing ways around this, but it won't be simple or easy.
I'm using MediaWiki 1.4rc1. I see in EditPage.php a function called getEditToolbar(), that then has an array of toolbar buttons.
Question 1: would this be the best/correct place to add my template text?
At least on Safari using 1.4 beta 5, the edit tool bar *does not* put the text in the edit box at the insertion point; it puts it in the little field above that, which you then have to copy-n-paste. Cumbersome. It would be nicer if it could plop it at the insertion point. (I have not seen this mentioned in the release notes for newer versions; apologies if it's been fixed.)
Question 2: Is it possible to get those edit buttons to prompt the user for data?
That's what the current buttons do -- did you try copying and modifying their code?
BTW: I just had great fun hacking SpecialListusers.php and QueryPage.php to display user info (which I've added additional fields to) in a table. (See http://www.IslandSeeds.org/wiki/Special:Listusers)
Since ListUsersPage->formatResult() only does one record, and the outer HTML construct is buried deep within QueryPage->doQuery(), is there any interest in factoring that part out so subclasses can override? Something like formatOpen(), formatClose(), and formatRecord().
(The last one is needed becasue the output of formatResult() is decorated with <li...>...</li> inside QueryPage->doQuery() -- perhaps this is best moved to formatRecord() instead?)
I'll do the work if it will get rolled in -- otherwise, I've just made my changes in-line via "$this->getName() == 'Listusers' ? ... : ..." which I don't like, but it'll be easier to merge in the next release than the more comprehensive solution.
:::: We are like tenant farmers chopping down the fence around our house for fuel when we should be using nature's inexhaustible sources of energy - sun, wind and tide. I'd put my money on the sun and solar energy. What a source of power! I hope we don't have to wait until oil and coal run out before we tackle that. -- Thomas Alva Edison (1847-1931) :::: Jan Steinman mailto:Jan@Bytesmiths.com/Item/80BF02
Jan Steinman wrote:
At least on Safari using 1.4 beta 5, the edit tool bar *does not* put the text in the edit box at the insertion point; it puts it in the little field above that, which you then have to copy-n-paste. Cumbersome. It would be nicer if it could plop it at the insertion point.
If you've ever tried to do JavaScript programming that manipulates data in a web browser, you'll know that different browsers behave differently, and sometimes you just can't get them to do what you want consistently.
I believe in IE/Win and Mozilla-based browsers it is able to insert text directly into the edit box, but in some others such as Safari it doesn't work right, so it's put in a separate box you cna look at as an example or cut-and-paste from.
BTW: I just had great fun hacking SpecialListusers.php and QueryPage.php to display user info (which I've added additional fields to) in a table. (See http://www.IslandSeeds.org/wiki/Special:Listusers)
Just checking, but are those phone numbers supposed to be displayed to the public?
Since ListUsersPage->formatResult() only does one record, and the outer HTML construct is buried deep within QueryPage->doQuery(), is there any interest in factoring that part out so subclasses can override? Something like formatOpen(), formatClose(), and formatRecord().
Might be worthwhile, yeah...
-- brion vibber (brion @ pobox.com)
mediawiki-l@lists.wikimedia.org