Get URL for mediawiki page given the Title - programmatically in PHP [closed]

本小妞迷上赌 提交于 2019-12-10 13:19:24

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!