tags:

views:

393

answers:

2

Hi, how can I get URL for an Article in MediaWiki given the title?

I want to create links to certain pages in the skin template programmatically using PHP right now I am doing this:

<a href="<?php $wgScriptPath ?>/index.php/Page_title">Page title</a>

Which is a bit too wordy, I'd like something

<?php page_link_by_title("Page_title") ?>

Thanks!

+1  A: 

Try this

$title = Title::newFromTest("Title");
$title->getFullURL();

That should create a new Title Class (svn.wikimedia.org/doc/classTitle.html), and retrieve the Full URL.

Chacha102
+3  A: 

The answer above should work fine except for a minor typo (Text instead of Test).

$title = Title::newFromText("Title");
$title->getFullURL();
Laurent Alquier