(Hope this doesn't post twice I sent it to the bounce address the first time.)
Hi again,
I'm using mediawiki 1.9.2 and I am writing an extension. This extension is supposed to take a list from several wiki pages and put information from the list into an infobox on a calling page. I tried looking at the all pages special page, but I was rather intimidated by the way it was requesting the list of pages. I tried looking at the list of Hooks on the mediawiki site. It is entirely possible that I am just dense, but I don't seem to be able to find a way to get an array of titles to process.
I feel like there should be an easy function getAllTitlesInNamespace(). But I haven't found it. Does anyone have a suggestion for getting all the page titles in the Main namespace?
Thanks very much! Courtney Christensen
This should do what you want where $namespace is either an exact namespace (like NS_MAIN) or an array of namespaces - like array(NS_MAIN, NS_CATEGORY):
$dbr =& wfGetDB( DB_SLAVE ); $res = $dbr->select( 'page_title', 'page', array( 'page_namespace' => $namespace ), __METHOD__, array( 'ORDER BY' => 'page_title' ) ); while ($obj = $dbr->fetchObject($res)) { $title = Title::newFromDBKey($obj->page_title); // do whatever you want with $title here } $dbr->freeResult($res);
Disclaimer: I have not tested the above code - having written it from memory. YMMV :)
-- Jim R. Wilson (jimbojw)
On 9/12/07, Christensen, Courtney ChristensenC@battelle.org wrote:
(Hope this doesn't post twice I sent it to the bounce address the first time.)
Hi again,
I'm using mediawiki 1.9.2 and I am writing an extension. This extension is supposed to take a list from several wiki pages and put information from the list into an infobox on a calling page. I tried looking at the all pages special page, but I was rather intimidated by the way it was requesting the list of pages. I tried looking at the list of Hooks on the mediawiki site. It is entirely possible that I am just dense, but I don't seem to be able to find a way to get an array of titles to process.
I feel like there should be an easy function getAllTitlesInNamespace(). But I haven't found it. Does anyone have a suggestion for getting all the page titles in the Main namespace?
Thanks very much! Courtney Christensen
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Thank you for this. It works almost perfect, expect that it seems to be finding links on the page it is called from only.
-----Original Message----- From: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] On Behalf Of Jim Wilson Sent: Wednesday, September 12, 2007 4:28 PM To: MediaWiki announcements and site admin list Subject: Re: [Mediawiki-l] how to get all page titles from within a script
This should do what you want where $namespace is either an exact namespace (like NS_MAIN) or an array of namespaces - like array(NS_MAIN, NS_CATEGORY):
$dbr =& wfGetDB( DB_SLAVE ); $res = $dbr->select( 'page_title', 'page', array( 'page_namespace' => $namespace ), __METHOD__, array( 'ORDER BY' => 'page_title' ) ); while ($obj = $dbr->fetchObject($res)) { $title = Title::newFromDBKey($obj->page_title); // do whatever you want with $title here } $dbr->freeResult($res);
Disclaimer: I have not tested the above code - having written it from memory. YMMV :)
-- Jim R. Wilson (jimbojw)
On 9/12/07, Christensen, Courtney ChristensenC@battelle.org wrote:
(Hope this doesn't post twice I sent it to the bounce address the
first
time.)
Hi again,
I'm using mediawiki 1.9.2 and I am writing an extension. This
extension
is supposed to take a list from several wiki pages and put information from the list into an infobox on a calling page. I tried looking at
the
all pages special page, but I was rather intimidated by the way it was requesting the list of pages. I tried looking at the list of Hooks on the mediawiki site. It is entirely possible that I am just dense, but
I
don't seem to be able to find a way to get an array of titles to process.
I feel like there should be an easy function
getAllTitlesInNamespace().
But I haven't found it. Does anyone have a suggestion for getting all the page titles in the Main namespace?
Thanks very much! Courtney Christensen
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Christensen, Courtney wrote:
(Hope this doesn't post twice I sent it to the bounce address the first time.)
Hi again,
I'm using mediawiki 1.9.2 and I am writing an extension. This extension is supposed to take a list from several wiki pages and put information from the list into an infobox on a calling page. I tried looking at the all pages special page, but I was rather intimidated by the way it was requesting the list of pages. I tried looking at the list of Hooks on the mediawiki site. It is entirely possible that I am just dense, but I don't seem to be able to find a way to get an array of titles to process.
I feel like there should be an easy function getAllTitlesInNamespace(). But I haven't found it. Does anyone have a suggestion for getting all the page titles in the Main namespace?
Have you looked at Dynamic Page List? It can easily do what you ask http://www.mediawiki.org/wiki/Extension:DynamicPageList
Cheers -- Frank
Thanks very much! Courtney Christensen
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org