I am looking to edit the link parsing code in MediaWiki. I would like [[Define:Something]] to create a mouse-over popup link message with the text contained on "Define:Something", and when you click it, it takes you to the Edit Article page for [[Define:Something]].
I have looked at the code contained in Parser.php, and I noticed that Image is a namespace:
if ( $ns == NS_IMAGE )
I know that I could make 'Define' a namespace, but how would I go about making the namespace and customizing its code?
------------- Beans-v6
Administrator, the-BEANS.com (http://www.the-beans.com/)
beans_v6@the-beans.com
On Mon, 21 Mar 2005 10:36:36 -0600, Beans-v6 beans_v6@the-beans.com wrote:
I know that I could make 'Define' a namespace, but how would I go about making the namespace and customizing its code?
Some thoughts and pointers, in no particular order: * http://meta.wikimedia.org/wiki/Help:Custom_namespaces - although namespaces oin general aren't really designed to behave completely differently in this way, so you may be better off hacking Parser.php (function replaceInternalLinks()) and Title.php, where the code determines "what to do about" them. * you might want to take a look at the template/inclusion code (some of which is in Parser.php, I think, though maybe not all) since you'll probably want to include the text of all the relevant target ("Define:") pages in the source (in the title attribute, or some more controllable JavaScript pop-up). * in fact, the feature "feels" more like a special case of inclusion than linking to me, but that's kind of up to you * the easier, though, less suited really, way of doing it is with an extension tag (similar to the <math>...</math> pairs) - see http://meta.wikimedia.org/wiki/Write_your_own_MediaWiki_extension e.g., something which would make <define>page=foo; text=bar</define> do what [[Define:Foo|Bar]] would in your example (if I understand you right) * finally, there's the "new style" extension code, event-and-hook style, which may or may not let you insert something anywhere appropriate, but is worth a mention - see docs/hooks.doc in your install for details.
Sounds like an intriguing project, but not an easy one (the parsing code, in particular, is notoriously ugly...) so happy hacking!
Indeed. Writing custom psuedo-namespaces is not easy. (I tried doing it once with nil success.)
On Mon, 21 Mar 2005 17:30:53 +0000, Rowan Collins rowan.collins@gmail.com wrote:
On Mon, 21 Mar 2005 10:36:36 -0600, Beans-v6 beans_v6@the-beans.com wrote:
I know that I could make 'Define' a namespace, but how would I go about making the namespace and customizing its code?
Some thoughts and pointers, in no particular order:
namespaces oin general aren't really designed to behave completely differently in this way, so you may be better off hacking Parser.php (function replaceInternalLinks()) and Title.php, where the code determines "what to do about" them.
- you might want to take a look at the template/inclusion code (some
of which is in Parser.php, I think, though maybe not all) since you'll probably want to include the text of all the relevant target ("Define:") pages in the source (in the title attribute, or some more controllable JavaScript pop-up).
- in fact, the feature "feels" more like a special case of inclusion
than linking to me, but that's kind of up to you
- the easier, though, less suited really, way of doing it is with an
extension tag (similar to the <math>...</math> pairs) - see http://meta.wikimedia.org/wiki/Write_your_own_MediaWiki_extension e.g., something which would make <define>page=foo; text=bar</define> do what [[Define:Foo|Bar]] would in your example (if I understand you right)
- finally, there's the "new style" extension code, event-and-hook
style, which may or may not let you insert something anywhere appropriate, but is worth a mention - see docs/hooks.doc in your install for details.
Sounds like an intriguing project, but not an easy one (the parsing code, in particular, is notoriously ugly...) so happy hacking!
-- Rowan Collins BSc [IMSoP] _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org