Extension talk:Dynamic Article List


 * Warning:: These pages can be modified by others. Use with caution!

PDF problem

 * Text version - DynamicArticleList.php
 * Text version - CategoryUtil.php
 * Text version - CategoryTravelerBase.php
 * Text version - CategoryNode.php

Yes I agree, sharing source code in PDF form is utterly retarded.

I couldn't get the extension to work - I get this message:

Parse error: parse error, unexpected T_CLASS in /home/mart1633/public_html/wiki/includes/CategoryTravelerBase.php on line 9

Steadymarvin 22:19, 11 January 2006 (UTC)

The method of cutting and pasting from pdfs seems unnecessarily complex - why not provide a zip of the files?

I have the same situation...
Parse error: parse error, unexpected T_CLASS in /home/dental/public_html/wiki/includes/CategoryTravelerBase.php on line 9

same problem
Parse error: parse error, unexpected T_CLASS in /home/worldnom/public_html/wiki/includes/CategoryTravelerBase.php on line 9

Ditto
Except my parse error is on line 2. A quick glance around and it looks like this may be a database error. Does this use the database? Do we need SQL code? Or does the PHP need to be configured somehow? --Laveaux 02:55, 5 February 2006 (UTC)

...Actually, something different is happening. I assume this requires Dynamic Page List to work. I get the parse error with that active, but when I "//" the "include("extensions/DynamicPageList.php");" line in LocalSettings, the parse error goes away, however the Dynamic Article List code does not work.

I have T_CLASS error too. Do you have php5?
This requires php5, i am using php 4.3.10-16.

I'll get php5 and hope it fixes it. Jcobbers

This fixes it: you NEED php5 http://www.debian-administration.org/articles/258 explains how for debian, googling around will explain for others. the basic process (for debian) is update the list of sources to include php5 and other required stuff.

"Found an article saying basically add the repositories to /etc/apt/sources.list and; apt-get update # Of course apt-get install libapache2-mod-php5 php5 php5-mysql" (from the link above).

Your mileage may differ, make sure you get the right php5-mysql version (check what version of mysql you have, <=4.0 or >= 4.1)

Only a white page
If i install this expension they way told here, then i only get a white Page with only HTML Headers and nothing else. I got PHP5, error_log from Server shows nothing. Im Using Mediawiki 1.5.6

And i don't got any Idea from what this error is coming.

Is there any alternative to Dynamic Article List ? Maybee something using PHP4

I have the same problem with version 1.5.6. Blank white page.

For PHP Version 4
(Does this code go in a file named DynamicArticleList.php? -> Yes, it does. And it works fine for me)

Issue is with the Category filter. Removed that from the script and now works in PHP 4. - Smcnaught (05:24, 1 April 2006 (UTC))

 Newly Posted Articles *     update          => Recently Updated Articles *     hot             => Most Popular Articles *     discussion      => Recently Updated Discussion * @author: Zeng Ji (zengji@gmail.com) * * To install, add following to LocalSettings.php * require_once ("extensions/DynamicArticleList.php"); */

$wgExtensionFunctions[] = "wfDynamicArticleList";

function wfDynamicArticleList { global $wgParser;

$wgParser->setHook( "DynamicArticleList", "DynamicArticleList" ); }

// The callback function for converting the input text to HTML output function DynamicArticleList( $input ) {

$dbr =& wfGetDB( DB_SLAVE );

// INVALIDATE CACHE global $wgTitle; $wgTitle->invalidateCache;

// Default Values $listTitle = false; $listType = 'new'; $listCount = 5;

// ###### PARSE PARAMETERS ###### $aParams = explode("\n", $input); foreach($aParams as $sParam) { $aParam = explode("=", $sParam); if( count( $aParam ) < 2 ) continue; $sType = trim($aParam[0]); $sArg = trim($aParam[1]);

switch ($sType) { case 'title': $listTitle = $sArg; break;

case 'type': if ( in_array($sArg, array('new','hot','update', 'discussion')) ) $listType = $sArg; break;

case 'count': $listCount = IntVal( $sArg ); break;

}      }

// ###### CHECKS ON PARAMETERS ###### if ($listTitle!=false && strlen($listTitle)==0) $listTitle=false;

// ###### BUILD SQL QUERY ###### $sql = genSQL($listType, $listCount);

// ###### PROCESS SQL QUERY ###### global $wgUser; global $wgLang; global $wgContLang;

$res = $dbr->query($sql); $sk =& $wgUser->getSkin; if ($dbr->numRows( $res ) != 0) { while( $row = $dbr->fetchObject ( $res ) ) { $title = Title::makeTitle( $row->namespace, $row->title); if ($listType == 'discussion') $sLink = $sk->makeKnownLinkObj($title, $wgContLang->convertHtml($title->getText), , , 'Discussion: '); else $sLink = $sk->makeKnownLinkObj($title, $wgContLang->convertHtml($title->getText));

// Generate 'View Count' String (for 'hot') if ($listType == 'hot') $aViews[] = ' - ( ' . $row->count . ' views ) '; else $aViews = false;

// Generate 'Time' String (for 'new', 'update', 'discussion') if ($listType != 'hot') { $aDates[] = ' - [ '. $wgLang->timeanddate($row->timestamp, true). ' ] ';                               $editorID = $row->user; if ($editorID == 0) { $editor = wfMsg('anonymous'); $aEditors[] = ' (' . $editor . ')'; } else { $editor = User::whoIs($editorID); $aEditors[] = ' ( ' . $sk->makeLink($wgContLang->getNsText(NS_USER). ':' . $editor, htmlspecialchars($editor)) . ' )'; }                     }         else { $aDates = false; $aEditors = false; }

$aArticles[] = $sLink; }      }       $dbr->freeResult( $res );

// ###### GENERATE OUTPUT ###### return OutputList($aArticles, $aEditors, $aDates, $aViews, $listTitle); }

function genSQL( $type, $count) { $dbr =& wfGetDB( DB_SLAVE ); $sPageTable = $dbr->tableName( 'page' ); $sRevisionTable = $dbr->tableName( 'revision' ); $sRecentChangesTable = $dbr->tableName( 'recentchanges' );

$sql = ''; if ($type == 'hot') {

$sql = "                            SELECT DISTINCT                             page_title as title,                             page_namespace AS namespace,                             page_counter as count                             FROM $sPageTable                             WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0 AND page_id!=1                             ORDER by count DESC                             LIMIT $count                     ";

} elseif ($type == 'update') {

// Step 1: Get revision list order by rev_id

$sql = "                           SELECT                             page_id,                             MAX(rev_id) AS max_rev_id                            FROM $sPageTable                            INNER JOIN $sRevisionTable ON page_id=rev_page

WHERE page_is_new!=1 AND page_namespace=0 AND page_is_redirect=0 AND page_id!=1 GROUP BY page_id ORDER by max_rev_id DESC LIMIT $count ";

// Step 2: According to revision list, generate SQL to retrieve article page information. $res = $dbr->query($sql); $inClause = ''; if ($dbr->numRows( $res ) == 0) { $inClause = "-1"; } else { while( $obj = $dbr->fetchObject( $res ) ) { if( isset( $obj->max_rev_id ) ) { $inClause .= $obj->max_rev_id. ',';                            }                     }                     $inClause = substr($inClause, 0, -1);   //delete tailing ',' }            $dbr->freeResult( $res );

$sql = "                    SELECT                      page_title AS title,                      page_namespace AS namespace,                      rev_user AS user,                      rev_timestamp AS timestamp                     FROM $sRevisionTable, $sPageTable                     WHERE rev_page=page_id AND rev_id IN (". $inClause . ")                     ORDER BY rev_id DESC";

} elseif ($type == 'discussion') {

// Step 1: Get revision list order by rev_id. $sql = "                            SELECT                              p1.page_id,                              MAX(rev_id) AS max_rev_id                             FROM $sPageTable AS p1                             INNER JOIN $sRevisionTable ON p1.page_id=rev_page                            WHERE p1.page_is_redirect=0 AND p1.page_namespace=1                            GROUP BY rev_page                            ORDER by max_rev_id DESC                            LIMIT $count                    ";

// Step 2: According to revision list, generate SQL to retrieve discussion page information. $res = $dbr->query($sql); $inClause = ''; if ($dbr->numRows( $res ) == 0) { $inClause = "-1"; } else { while( $obj = $dbr->fetchObject( $res ) ) { if( isset( $obj->max_rev_id ) ) { $inClause .= $obj->max_rev_id. ',';                           }                    }                    $inClause = substr($inClause, 0, -1);        //delete tailing ',' }           $dbr->freeResult( $res );

$sql = "                   SELECT                     page_title AS title,                     page_namespace AS namespace,                     rev_user AS user,                     rev_timestamp AS timestamp                    FROM $sRevisionTable, $sPageTable                    WHERE rev_page=page_id AND rev_id IN (". $inClause . ")                    ORDER BY rev_id DESC";

}    else { // default type is 'new'

$sql = "                              SELECT DISTINCT                                page_title AS title,                                page_namespace AS namespace,                                rc_user AS user,                                rc_timestamp AS timestamp                               FROM $sPageTable                               INNER JOIN $sRecentChangesTable ON page_id=rc_cur_id                               WHERE rc_new=1 AND rc_namespace=0 AND page_is_redirect=0 AND page_id!=1                               ORDER by rc_id DESC                               LIMIT $count                      "; }

return $sql; }

function OutputList ( $aArticles, $aEditors, $aDates, $aViews, $listTitle ) { if ($listTitle != false) { $r .= " ". $listTitle. " \n"; $r .= " \n"; }

$sStartList = ''; $sEndList = ''; $sStartItem = ''; $sEndItem = '';

$r .= $sStartList. "\n"; for ($i=0; $i". $aEditors[$i]. " ";              if ($aDates != false) $dateString = "". $aDates[$i]. " ";              if ($aViews != false) $viewString = "". $aViews[$i]. " ";

$r .= $sStartItem. $aArticles[$i]. $editorString. $dateString. $viewString. $sEndItem. "\n"; }      $r .= $sEndList. "\n";

return $r; } ?>

Mediawiki 1.6.3
Is there a Chance anyone can make this and DynamicPageList working with mediawiki 1.6.3 ?

Mediawiki 1.6.5
Would be most grateful if anyone could make DynamicPageList work with mediawiki 1.6.5. Had no luck myself.

Slow Updating?
On the above note i have this working with mediawiki 1.6.7 fine. However, it seems to take a very long time to refresh the lists. The new articles updates within a few hours, but the recentchanges can sometimes take days to refresh. Does anyone else have the problem or a fix? (I have turned off mediawiki clearing the recent changes aswel)l btw. --202.72.148.102 02:49, 6 July 2006 (UTC)

Mediawiki 1.6.7
It works with Mediawiki 1.6.7 but .... I have to use the Dynamic_Article_List_for_PHP4 code to make it works even if I have PHP 5.1.2 installed. I have tried the PDF version of the code and the text file version provided above with no luck. The problem is that I have PHP 5.1.2 (My server is Windows 2003 and IIS is used as web server) and I have the same T_CLASS error if I try to use the extension Dynamic Article List. I am not a PHP programmer but it seems to me a bug related to this extension and not PHP.

Update

Upgraded to PHP 5.1.4 (full stuff) and have this error :

Parse error: parse error, unexpected T_STRING, expecting T_FUNCTION in D:\mediawiki\includes\CategoryTravelerBase.php on line 158

Update 2

Ok, I have donwloaded and install all code from the PDF files to be sure (the error message above indicate maybe that there is a conflict somewhere in the function calls) and receive this error this time :

A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was: (SQL query hidden) from within function "CategoryUtil::buildOneCategory".

MySQL returned error "1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

for the right syntax to use near 's_Group_Policies') ORDER BY page_title' at line 1 (localhost)".

Fix :

This error is because I use the option 'categoryRoot' with the wrong name, I have to use the category name and NOT the Category display name.

--Romainp 17:52, 7 July 2006 (UTC)

Feture Request
Is there a way to get new and update together with the time order. for ex. B (new) A (updated) C (new) D (new)

Mediawiki 1.7.1
Just to let you know that I have upgraded from 1.6.x to 1.7.1 and the extension works, however, I have noticed those bugs :

Bug1 : Can't purge or preview the page

Everytime I try to purge the cache for a page that have the extension, or when I want to preview it, I have got this error :

Notice: Undefined variable:r in D:\mediawiki\extensions\DynamicArticleList.php on line 311

Bug2 : The option 'CategoryRoot' does not seems to work well

I have a general category called 'Knowledge Base' with several subs categories. If I use the extension to see all the latest articles in the 'Knowledge Base' Category, I have got also some articles that are not in this category but contains the words 'Knowledge Base'.

Maybe it is a bug in the query or the extension, maybe the problem is located elsewhere (the caching of the page ??).

Please everybody comment about that if you have the same problem.

Update : Ok, I think that the problem is not related to the name of the category but with the fact that the extension does not seems to work well to retreive all articles in sub categories, starting with a root category. I have an SQL Error each time I try to run it :

A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was: (SQL query hidden)

from within function "CategoryUtil::buildOneCategory". MySQL returned error "1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's_Group_Policies') ORDER BY page_title' at line 1 (localhost)".

With the parameters :

 title=Newly Posted Articles type=new count=5 categoryRoot=Knowledge Base 

Is it possible that the code maintainer or the actual coder of this great extension can help us ?

Fix : In fact, my problem was that use the ' caracter in a category name and that bot seem to make mediawiki happy. I have created a new category and remove the problematic category (by remving in it the root category) and now all is working perfectly !

--Romainp 13:52, 10 July 2006 (UTC)

I have the same error: Database error From Front Tools wiki Jump to: navigation, search A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was:

(SQL query hidden)

from within function "". MySQL returned error "1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER by rc_id DESC LIMIT 5' at line 9 (localhost)". But i'm not sure to understand how you have solved yout pb ! Any help is welcome --Ctof 18:13, 24 July 2006 (UTC)


 * This error seems to occur any time the category does not exist, which means, in particular, that it doesn't work in templates. (The  tag is executed before the substitution, so unless you have a category called it fails.) I've been looking through the code to find a better way to handle query failuers, but if anyone knows one, that would be great. --Jimmy 18:42, 24 July 2006 (UTC)

Bug 3 : categoryRoot=MyCat dosn't list the sames numbers of article as when we click on a link like  ? --Ctof 11:34, 27 July 2006 (UTC)


 * after readinf the code,I know what, it's because by default the sql request is limited to the default namespace and i have article ino other namespace. is it possbible to add an attribute to specify the namespace ? --Ctof 13:34, 27 July 2006 (UTC)

Wikimarkup Feature
Is it possible to allow Wikimarkup, particularly links, in the title field?

Two New Features
I added two features to Zeng Ji's great extension: I included the code on my user page at User:Socoljam/DynamicArticleList (enhanced). I hope someone finds this useful, besides myself that is! --Socoljam 23:25, 23 July 2006 (UTC)
 * Options to surpress view count, editor, and timestamp, as pertain to each list type
 * Renders wikitext in the title field

Error when used with DPL
When using DynamicArticleList on the same page as DynamicPageList2 I get one of these errors for each use of DynamicArticleList :- Notice: Undefined variable: r in /my/site/directory/wiki/extensions/DynamicArticleList.php on line 282 My System :-
 * MediaWiki: 1.7.1
 * PHP: 5.0.5-2ubuntu1.3 (apache2handler)
 * MySQL: 4.0.24_Debian-10ubuntu2.3-log

A fix?

I had it happening on line 274/275, so changed them to look like this:

if (isset($r)) { $r .= " ". $listTitle. " \n"; } if (isset($r)) { $r .= " \n"; }

Appears to work for me!

If you are having errors, make sure code copy from pdf was good
I had two spurrious newlines that got inserted into the code in CategoryTravelerBase.php. This caused odd "unexpected T_STRING expected T_FUNCTION ..." type errors, similar to what other people have reported on this page. 71.142.84.12 14:34, 29 September 2006 (UTC)

The "Undefined variable: r" error
I have Mediawiki 1.8.1 and the extension installed (from the PDF file).

I have also the "Undefined variable: r" in several lines. I have tested the fix describe above : if (isset($r)) { $r .= " ". $listTitle. " \n"; } if (isset($r)) { $r .= " \n"; }

I have apply the if (isset(%r)) {...} on each lines where I have an error AND where the r variable appear. Now there is no errors but ... the extension does not work anymore ...

Any ideas someone ?

--Romain 14:50, 18 October 2006 (UTC)


 * I'm just adding in that I'm having the error, with the fix applied, on version 1.8.3, PHP 5.1.2, and MySQL 4.1.14-Debian_5-log. The script still appears to work for me, though, except that I need to go into the page with the dynamic lists, edit, and save the page to update the lists.  Refreshing the page clears the errors, but it doesn't update the lists.  Er, I'd also like support on getting this so I don't need to edit pages to update lists... It kinda defeats the whole "Dynamic" part of the script. --216.170.23.236 04:20, 30 January 2007 (UTC)

--Special:Contributions 13:59, 14 March 2011 (UTC) Just add $r = ""; after the function OutputList in line 274. It will work!

Mediawiki 1.8.2
I got the pdf version and that works fine

Using Namespaces
I add a feature in the file Text version - DynamicArticleList.php with namespace: choice of namespace for the listing.

You can use the name or directly the number of the namespace.

Use like that :  title=my_listing type=new count=5 namespace=my_namespace categoryRoot=my_category 

Ncante 09:53, 14 February 2007 (UTC)

Mediawiki 1.9.2 with Namespace version
I have downloaded the Text version - DynamicArticleList.php with namespace Fixed the Undefined variable:r error by adding $r = ""; at the start of the OutputList function.

As people have said at the end of this discussion it is not updating.

I have added the $wgCacheEpoch = gmdate( 'YmdHis' ); line and when I specify a namespace it seems to work, but on my home page, where I want to check all namespaces it is just not updating even if I edit the page.

--Markw21 20:42, 9 March 2007 (UTC)

Problem with refresh?
At first i thought, that all works well, but it doesn't. This dynamic List don't refresh. Only if i edit something on the page, where my dynamic list is. I must say, that i have not done what is described in Dynamic_Article_List. I have version 1.9.2 Can anyone help me? --192.164.38.126 08:45, 22 February 2007 (UTC)

I am reporting the same problem. Just moved from 1.6.7 to 1.9.3 and my dynamic article list doesn't refresh anymore. Only when I am saving the page with the list again. In 1.6.7 it DID refresh very well grz B.Vahrmeijer - LeerWiki.nl

Solved Vahrmeijer 9-3-2007 see http://www.leerwiki.nl use in Localsettings: $wgCacheEpoch = gmdate( 'YmdHis' );

No refresh for me either.
My 1.93 wiki is also having trouble with main page updates.

I have placed $wgCacheEpoch = gmdate( 'YmdHis' ); into the local setting file, but the page still only updates when I edit/save. I really like having the recent changes on the front page and would like to get this feature working. Has anyone else fixed this issue?

Thanks

Incompatibility with Semantic MediaWiki?
I installed the DynamicAL put three lists on my Main_Page and upon accessing it or refreshing it I get a JavaScript alert-like box saying "Failed to derive URL prefix for Timeline API code files" the worst thing is that that after clicking "OK" or closing the alert box I get a completely correctly rendered page as usual.

So and since WikiMedia is very user friendly software that anyone even users with basic knowledge can use I had to search the entire file system as to what could the cryptic "Timeline API" stand for. The only fiel on my computer having a reference to timeline api is a javascript file for SimileTimeline - a fancy DHTML-based AJAXy widget for visualizing time-based events, that comes with Semantic MediaWiki (I would've never known I have it lol). Any help would be appreciated (although I'll prolly simply have to dump one of the extensions to solve this :D)

for refernce here's the timeline-api.js 354d 15:58, 28 September 2007 (UTC)

Warning: Cannot modify header information
I installed the extension in MediaWiki 1.11.0 and got two times the warning: Warning: Cannot modify header information - headers already sent by (output started at /mediawiki-1.11.0/extensions/DynamicArticleList.php:307) in /mediawiki-1.11.0/includes/WebResponse.php on line 10 and german umlaute like ä, ö, ü ... will not be displayed.

--AlexSommer 14:22, 5 October 2007 (UTC)

The same Problem with MediaWiki 1.10.0
Warning: Cannot modify header information - headers already sent by (output started at /usr/share/mediawiki-extensions/DynamicArticleList/DynamicArticleList.php:298) in /usr/share/mediawiki1.10/includes/WebResponse.php on line 10

not realy a Solution
i' ve put following lines in index.php:

error_reporting( E_ALL ); header( "Content-type: text/html; charset=utf-8" ); @ini_set( "display_errors", false );

the pdf files are shit
i thought that's my iceweasel, which make this problem. then i download those *.pdf (aka php) files with wget, and with other programs and i allways get strange pdf like file encoded dadaistical texts. i realy don't understand why there is an file.extension upload restructor in mediawiki. i had to install acrobatreader and to copy out these files.

Blank page with 1.11
I upgraded to 1.11 and now when I enable this extension I just get blank pages. Anyone willing to update this extension ?

Refresh
mediawiki 1.32. How to make it refresh properly?

Feature Request: hideminor for update
For the type "update" a feature only to show the majorupdates would be perfect. The "recentchanges" List has the possiblility to hide minorupdates. Maybe it is possible to integrate this. With the mark of minorupdates on updated pages the editor could decide if the change should be diplayed in the Dynamic list.

MediaWiki 1.16
Worked for me with MediaWiki 1.16.

I copied all 4 php files into $IP/extensions/DynamicArticleList

I added require_once( "$IP/extensions/DynamicArticleList/DynamicArticleList.php" ); to my LocalSettings.php

All worked as expected.

jcoreil 2010-08-03

Mediawiki 1.15
It works for me, but if I turn on error display

- adding near top to LocalSettings.php

I see the following error repeated 4 times.

Notice: Undefined variable: r in C:\htdocs\wkbv_wiki_copy\extensions\DynamicArticleList\DynamicArticleList.php on line 266

--Mark 10:21, 15 September 2010 (UTC)

How to change output of type=new
The output shown for the DynamicArticleList when set to type=new includes the title, the author and the date/time it was created.

I would like only the title to be shown. Does anyone have the expertise to share how this might be done? What file do I need to adjust and what lines do I need to edit/delete? Thanks!!