Sorry for not answering so quickly,
YOUR ENTRIES
My extension should work for you independently of the namespace (as Rowan stated) You just have to make in your entry: - a [[Category:Blog]] link and - a link to the frontpage of your blog (let's call it John_Blog)
And then, with <blog>cat=Blog<blog> or <blog>page=John_Blog;cat=Blog<blog> in your John_Blog page, you should see all the entries. That's the good news.
LIMITS:
Now, if you want to have entries only ten by ten, it's fairly easy (well, I suppose :-)): just add the sql instruction for limits (don't forget to make a sort by ID before):let's call them $from and $to (beware, in the Special:Allpages, $from refers to the name of the page, I will use the number)
global $wgUseCategoryMagic, $wgUser,$wgParser,$parserOptions,$wgTitle, $wgOut,$wgLinkCache,$from,$to;
$ns = $wgRequest->getVal( 'ns' ); if(!isset($ns)) $ns = 0; $from = $wgRequest->getVal( 'from' ); if(!isset($from)) $ns = 0; $to = $wgRequest->getVal( 'to' ); if(!isset($to)) $to = 10;
And the sql should look like:
$sql = "SELECT cur_id,cur_namespace,cur_title,cur_text, cur_is_redirect FROM links,cur,categorylinks WHERE l_to={$lid} AND l_from=cur_id AND cl_from=cur_id AND cl_to='$cat' ORDER BY `cur_id` DESC LIMIT $from , $to";
LINKS: ask ROWAN :-)
My problem is in the creation of the links: for all the entries (from 1to 10, 10to 20). How can I catch the number of entries, without making twice the query (one for counting, one for displaying)? Sorry, I'm in HR, php is just a hobby ;-)
Hope it helps. François
John Yu wrote:
Thanks Rowan and Francois.
Francois, I'll give your current extension a try. I think it helps a lot already.
But, ideally, it will be nice to have a blog extension that does this: I create entries like "Blog:2005/03/04/Francois created world's first blog extension for mediawiki". Then on the frontpage, I can put <blog>ns=Blog;entriesPerPage=10</blog> and it will show the latest 10 entries, with a "view next 10" link to show the 2nd page, etc. -- John
FxParlant wrote:
Hi John
Rowan Collins is absolutely right, the extension failed on my localhost because of corruption of the "recent change" table, but it perfectly worked on my website.
I'll try to build a real blog extension, capable of sorting pages by months, and / or by category, inside a namespace.
Should it be an extension or a special page ?
What can the url be:
- Ns:Blog?year=2005&month=02&category=Cinema
- Ns:Blog?start=01-02-2005&end=28-02-2005&Category=Books
Anyway, I first need to catch a little bit with mysql timestamp manipulation :-\
François
FxParlant wrote:
Hi John,
I hadn't tried this yet.. but just for you I tried... ;-)
I remembered why I just droped the idea of using namespaces in mediawiki (although I really used it a lot in Dokuwiki): I think that mediawiki just creates a "what links here" (links) table for the main namespace.
I thought I could simply change the mysql query of my extension, but it seems that it's the same with the "category links" table: only pages in the main namespace are taken into account.
Therefore, I think you could change the sql query, and instead of searching page with backlinks to the page, just query pages from your blog namespace, and sort them by date... that is, create a proper blog extension, instead of my complicated quote version :-)))
I really think it would be simpler of my version, because you wouldn't have to take care of pages having links to themselves through fragment incorporated, all this getting infinite loop.
Do you need a bit of help on this ?
François
John Yu wrote:
François,
Will your extension work for pages in namespaces other than the main one? I'm interested to try it out, but I keep our blog-oriented entries in custom namespace.
Thanks.
John
MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l