问题
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:
The answer above should work fine except for a minor typo (Text instead of Test).
$title = Title::newFromText("Title");
$title->getFullURL();
回答2:
Try this
$title = Title::newFromText("Title");
$title->getFullURL();
That should create a new Title Class (svn.wikimedia.org/doc/classTitle.html), and retrieve the Full URL.
来源:https://stackoverflow.com/questions/1210230/get-url-for-mediawiki-page-given-the-title-programmatically-in-php