[Mediawiki-l] Internal link with query string?

Jim Wilson wilson.jim.r at gmail.com
Mon May 7 21:20:59 UTC 2007


I see,

Well, the next thing I'd try is an interwiki link.  It may do the processing
at the right time to do what you want.

Another easy (but hackier) way to do it is to wrap some of the msg in divs
or spans with ids, then add something to your MediaWiki:Common.js to look
for these inject the links you want.

So the msg might be this:

<div id="nosuchpage">'''There is no page titled "<span
id="badtitle">$1</span>".''' You can [[:$1|create this page]].</div>

And then your Common.js might have this (be warned - has not been tested):

----------------------------------------------
addOnloadHook( function () {
    var div = document.getElementById('nosuchpage');
    if (div) {
        var title = document.getElementById('badtitle').innerHTML;
        var href =
"/path/to/your/wiki/index.php?title=Special:Whatever&arg=" +
encodeURI(title);
        div.innerHTML += " or using <a href='" + href + "'> a standard
article type ";
    }
});
----------------------------------------------

A slightly more difficult option would be to hijack the SpecialSearch class
altogether and replace it with a subclass that injects your custom msg
processing.  I'm not sure how hard this would be or if there are even
appropriate hooks to do it - but it's a cleaner solution than the JS one
above if it can be done.

-- Jim

On 5/7/07, Daniel Barrett <danb at vistaprint.com> wrote:
>
> >Well, you probably want to avoid modifying the core code if at all
> possible
> >- it will make future upgrades much more difficult if you do.
>
> I agree, though we encapsulate our changes pretty well using Subversion
> "vendor branches."
>
> >I really don't understand enough about the problem to help
> >- it seems you're trying to mix wikitext, wfMsg text and php code
> >- so I'm confused as to what you're trying to do.  What's the end goal?
>
> Sure: here's the background.
>
> At my company, we want our wiki pages to contain certain standard
> information: an introductory overview, a "Foo" heading, a "Bar"
> subheading, etc.  In fact, we have numerous "standard" article types:
> New Project page, Requirements Document page, Technical Spec page,
> Laundry List page, etc.  I want to define these types, and when the user
> edits a brand new article of these types, we want some standard, initial
> wikitext automatically inserted into the editor.
>
> I have evaluated several extensions that do similar things, but they are
> all limited in various ways.  (I can go into detail if desired.)
>
> So I wrote a Special page that presents the user with a dropdown list of
> these "preset" article types:   Select one, enter an article name, and
> you're dropped into the editor with the correct starting wikitext ready
> to go.  Want a requirements document? Just select Requirements Document,
> enter an article name, and click Submit.  You're in the editor.
>
> This works fine as a Special page.  But now I want to modify
> Special:Search to link to my Special page. Instead of displaying:
>
>   '''There is no page titled "$1".''' You can [[:$1|create this page]].
>
> I want it to offer the user a choice between a blank page or a standard
> article type:
>
>   '''There is no page titled "$1".''' You can create this page
> [[:$1|blank]] or using
> [[{{fullurl:Special:MyPresetPageTypes|arg={{urlencode:$1}}}} a standard
> article type]]
>
> In other words, within wikitext, I want to reference the search term
> that was passed to Special:Search, so I can pass it in turn to my own
> special page, Special:MyPresetPageTypes.
>
> The underlying problem is how to pass this value from within wikitext to
> Special:MyPresetPageTypes. Perhaps there's a way to do this without a
> query parameter.
>
> Thanks for any advice.
>
> DanB
>
> ---------------------
> Confidentiality note
> The information in this email and any attachment may contain confidential
> and proprietary information of VistaPrint and/or its affiliates and may be
> privileged or otherwise protected from disclosure. If you are not the
> intended recipient, you are hereby notified that any review, reliance or
> distribution by others or forwarding without express permission is strictly
> prohibited and may cause liability. In case you have received this message
> due to an error in transmission, please notify the sender immediately and
> delete this email and any attachment from your system.
> ---------------------
>
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l at lists.wikimedia.org
> http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>


More information about the MediaWiki-l mailing list