Extension talk:DynamicPageList (Wikimedia)

From MediaWiki.org
Jump to: navigation, search
Start a new discussion
First page
First page
Previous page
Previous page
Last page
Last page

OR-operator for category

I can't figure out, how to use an OR Operator for the categories:

<DynamicPageList>
category = Category1
category = Category2
</DynamicPageList>

Output: DLP shows only items, which are in both categories. Category1 AND Category2

I wish to combine the out in this manner: Category1 OR Category2. Is there an OR-Operator?

Bertram Simon15:14, 30 January 2012

I don't think that is possible with this extension.

Helder20:48, 30 January 2012

Helder is correct, such a feature is not implemented in the Wikimedia version of this extension.

Bawolff03:26, 31 January 2012
 

Thank you for your answers. It is a pity. I use DLP for the frontpage of an business-wiki and want to show the last 5 entries of 3 categories.

SimonWpt11:44, 1 February 2012

Well if you're not overly concerned about order you could do something like:

<DynamicPageList>
category = Category1
</DynamicPageList>
<DynamicPageList>
category = Category2
</DynamicPageList>

and it will look like one list (you can even use limit and offset parameters to make the lists interleved). Very far from an ideal solution though.

Bawolff01:17, 2 February 2012

And if you are interested in alphabetical order, you could use JavaScript to sort the resulting list.

Helder12:14, 2 February 2012
 

That's the way, I use it now:)

SimonWpt16:50, 6 February 2012
 
 
 
 

List doesn't refresh when categories are changed

I'm using DPL, but I'm finding the list doesn't actually refresh unless I edit the page it's on. For example, I put this on a "Category Intersection" page:

<DynamicPageList>
category = CategoryOne
category = CategoryTwo
</DynamicPageList>

It correctly displays all the pages in both categories. However if I edit one of the listed pages and change it from CategoryOne to CategoryThree, I'd expect a refresh to drop it from the list. It doesn't. If I edit the "Category Intersection" page and save, the list refreshes.

Is this the expected behavior?

JasonPenney21:43, 6 January 2012

Update: it appears to handle adds correctly, but not subtractions. If a page joins a category listed in the DPL tag, it shows up after a refresh. If a page is removed from a category in the DPL tag, the page with the tag must be edited before the item drops from the list.

JasonPenney21:57, 6 January 2012
 

This is expected behaviour (as a compromise between giving super up to date output and performance) See bugzilla:11685.

Bawolff22:14, 6 January 2012
 

New feature parameter: categorymatch

The third-party-version of this addon (found here) supports the very useful parameter categorymatch. On my wiki, this is used to collect articles from categories with similar names. After switching to the Intersection-Addon, I missed this feature. so I added it myself. Maybe other users are also interested in this, so here is the udiff for DynamicPageList.php

Usage:

<DynamicPageList>
category=MustBeExtended
categorymatch=%fruit%|%vegetables%
notcategory=electronics
</DynamicPageList>

This will find any aticles in categories with names like fruit and vegetables which also are contained in the category MustBeExtended.

- Odysseus277 16:01, 4 January 2012 (UTC)

--- X:\Scripte\intersection\DynamicPageList.php 2011-11-14 17:31:42.000000000 +0100
+++ X:\xampp\htdocs\wiki\mediawiki\extensions\intersection\DynamicPageList.php  2012-01-04 17:25:23.000000000 +0100
@@ -114,12 +114,13 @@
        $addFirstCategoryDate = false;
        $dateFormat = '';
        $stripYear = false;
 
        $linkOptions = array();
        $categories = array();
+       $categoryMatches = array();
        $excludeCategories = array();
 
        $parameters = explode( "\n", $input );
 
        $parser = new Parser;
        $poptions = new ParserOptions;
@@ -146,12 +147,33 @@
                                        $parser->transformMsg( $arg, $poptions )
                                );
                                if( is_null( $title ) ) {
                                        continue;
                                }
                                $excludeCategories[] = $title;
+                               break;
+                       case 'categorymatch':
+                               $matchedCategories = explode('|', $arg);
+                               foreach($matchedCategories as $currentCategory) {
+                                       $value = null;
+                                       if(preg_match("/^\%[^%]*\%$/i", $currentCategory)) {
+                                               $value = mysql_real_escape_string(str_replace('%', '', $currentCategory));
+                                               $value = '%' . $value . '%';
+                                       } elseif(preg_match("/^\%[^%]*$/i", $currentCategory)) {
+                                               $value = mysql_real_escape_string(str_replace('%', '', $currentCategory));
+                                               $value = '%' . $value;
+                                       } elseif(preg_match("/^[^%]*\%$$/i", $currentCategory)) {
+                                               $value = mysql_real_escape_string(str_replace('%', '', $currentCategory));
+                                               $value = $value . '%';
+                                       }
+                    
+                                       if( is_null($value) ) continue;
+                    
+                                       $title = Title::newFromText( $parser->transformMsg( $value, $poptions ) );
+                                       $categoryMatches[] = $title;
+                               }
                                break;
                        case 'namespace':
                                $ns = $wgContLang->getNsIndex( $arg );
                                if ( $ns != null ) {
                                        $namespaceIndex = $ns;
                                        $namespaceFiltering = true;
@@ -386,13 +408,14 @@
                                break;
                } // end main switch()
        } // end foreach()
 
        $catCount = count( $categories );
        $excludeCatCount = count( $excludeCategories );
-       $totalCatCount = $catCount + $excludeCatCount;
+       $catMatchCount = empty($categoryMatches) ? 0 : 1;
+       $totalCatCount = $catCount + $excludeCatCount + $catMatchCount;
 
        if ( $catCount < 1 && false == $namespaceFiltering ) {
                if ( $suppressErrors == false ) {
                        return htmlspecialchars( wfMsgForContent( 'intersection_noincludecats' ) ); // "!!no included categories!!";
                } else {
                        return '';
@@ -428,13 +451,13 @@
                }
        }
 
        // build the SQL query
        $dbr = wfGetDB( DB_SLAVE );
        $tables = array( 'page' );
-       $fields = array( 'page_namespace', 'page_title' );
+       $fields = array( 'DISTINCT page_id', 'page_namespace', 'page_title' );
        $where = array();
        $join = array();
        $options = array();
 
        if ( $googleHack ) {
                $fields[] = 'page_id';
@@ -487,19 +510,38 @@
 
        for ( $i = 0; $i < $catCount; $i++ ) {
                $join["$categorylinks AS c$currentTableNumber"] = array(
                        'INNER JOIN',
                        array(
                                "page_id = c{$currentTableNumber}.cl_from",
-                               "c{$currentTableNumber}.cl_to={$dbr->addQuotes( $categories[$i]->getDBKey() )}"
+                               "c{$currentTableNumber}.cl_to={$dbr->addQuotes( $categories[$i]->getDBKey() )}"
                        )
                );
                $tables[] = "$categorylinks AS c$currentTableNumber";
 
                $currentTableNumber++;
        }
+       
+       if( !empty($categoryMatches) ) {
+               $onStatements = array();
+               
+               foreach( $categoryMatches as $categoryMatch ) {
+                       $onStatements[] = "LOWER(c{$currentTableNumber}.cl_to) LIKE LOWER({$dbr->addQuotes( $categoryMatch->getDBKey() )})";
+               }
+               
+               $join["$categorylinks AS c$currentTableNumber"] = array(
+                       'INNER JOIN',
+                       array(
+                               "page_id = c{$currentTableNumber}.cl_from",
+                               implode(' OR ', $onStatements)
+                       )
+               );
+               $tables[] = "$categorylinks AS c$currentTableNumber";
+
+               $currentTableNumber++;          
+       }
 
        for ( $i = 0; $i < $excludeCatCount; $i++ ) {
                $join["$categorylinks AS c$currentTableNumber"] = array(
                        'LEFT OUTER JOIN',
                        array(
                                "page_id = c{$currentTableNumber}.cl_from",
188.192.164.18216:01, 4 January 2012

No ordermethod = title

<DynamicPageList>
namespace   = help
ordermethod = title
</DynamicPageList>

That falls back to created. There is no way to force proper sorting by title without filtering by categories. That query does make sense on small company wikis... Anyway, fix:

                                switch ( $arg ) {
                                        case 'title':
                                                $orderMethod = 'title';
                                                break;

and

        switch ( $orderMethod ) {
                case 'title':
                        $sqlSort = 'page_title';
                        break;
Subfader15:48, 14 December 2011

Note, its cheaper to sort by page_namespace, page_title - but then things are ordered by namespace.

Bawolff06:13, 15 December 2011

Good to know. Thanks.

Subfader08:56, 15 December 2011
 
 

Cannot use variables

I want to use this in a template

<DynamicPageList>
namespace = {{NAMESPACE}}
redirect = none
</DynamicPageList>

But it doesn't work, nor as passed parameter. It doesn't even work on pages directly:

<DynamicPageList>
namespace = {{NAMESPACE}}
ordermethod = popularity
order = descending
redirect = none
</DynamicPageList>

The (main) namepsace is used instead. Bug? (MW 1.18 here)

Subfader16:04, 14 December 2011

I've not tested, but you could try to use #tag:dynamicpagelist as in wikibooks:Template:CategoryList

{{#tag:dynamicpagelist|
namespace = {{NAMESPACE}}
ordermethod = popularity
order = descending
redirect = none
}}
Helder16:24, 14 December 2011

Yep. Cheers!

Subfader17:16, 14 December 2011

Yep, #tag:dynamicpagelist is the required solution. Variables are only interpreted in some parameters, of which namespace is not one. It does main namespace since it considers anything that's not a namespace name to be the main namespace (so people can use things like 'main' ).

Cheers.

Bawolff06:11, 15 December 2011
 
 
 

Is it possible to add information from 'Labelled Page Transclusion' extension to the DPL List?

With Dynamic Page List (Third Party) I had a template which showed the introductory paragraphs of every page in a given category.

Unfortunately I can't get that to work any more, so have installed Dynamic Page List (Mediawiki) (which can list pages in a category) and Labelled Section Transclusion (which can transclude the introductory paragraph of an individual page).

I wonder whether there is any way of linking the two modules, so that DPL (Mediawiki) adds the information from LST to its list. Alternatively, can you recommend any other extension(s)?

Thanks in advance.

Jonathan320:09, 11 December 2011

No, they can't be linked at the moment.

Perhaps SMW can do what you want.

Bawolff22:29, 13 December 2011
 

Does it work with MW 1.18?

Sadly the 'other' DynamicPageList (third party one) breaks MW 1.18. Does anyone happen to know if this extension works with 1.18? Thank you! Jonathan3 01:05, 11 December 2011 (UTC)

Jonathan301:05, 11 December 2011

Yes it does. This extension is in use on Wikimedia wikis (like wikinews) which run 1.18.

Note: The code for the two extensions differ quite a bit, so if one is broken in some way, probably doesn't mean too much about the other one.

Bawolff18:31, 11 December 2011

Thank you very much. I have downloaded it and it works fine. I've got a question about it, though - which I'll post separately. Best wishes, Jonathan3 20:02, 11 December 2011 (UTC)

Jonathan320:02, 11 December 2011
 
 

Question about "includematch"

I use this great extensions in two of mine wikis. In the last times, i have some problems with includematch. My Wiki is about Final Fantasy XIV Online, for info ;)

NPCs are selling some Items, the item goes in the category:example sells from NPC. Now, some NPCs sells example-head, examplefeed, example-earring. If i create now the Article examlpe, i use this DPL:

{{#dpl:
|category = {{SUBPAGENAME}} sells from NPC
|namespace =
|includepage = {Sellsrow}:Price, {NPC} dpl Zones
|includematch =  /\s*Item\s*{{=}}\s*{{fixapos|{{fixtick|{{fixparen|{{SUBPAGENAME}}}}}}}}/si
|format      =,,\n
|table       =class="SE-Heaventable sortable" style="width: 100%;",Name,Preis,Region
|columns=1
|rowcolformat= style="background-color: transparent; width: 100%;"
|tablerow = %%,%%
|suppresserrors=true
}}

Here i use the _Template:Sellsrow to get the Price and the Template:NPC dpl Zones to get all other datas. In the Template:Sellsrow, i define Item. Thats why my includematch say get where Item = {{SUBPAGENAME}}. So, my Articles shows me now in the Table all sellinginformations about:

  • example
  • example-head
  • examplefeed
  • example-earring

i try'd some other includematch variations like this:

{{#dpl:
|category = {{#if: {{{Name|}}}|{{{Name|}}}|{{PAGENAME}}}} sells from NPC
|namespace =
|includepage = {Sellsrow}:Price, {NPC} dpl Zones
|includematch =  /\s*Item\s*{{=}}\s*{{#if: {{{Name|}}}|{{{Name|}}}|{{PAGENAME}}}}/si
|format      =,,\n
|table       =class="SE-Heaventable sortable" style="width: 100%;",Name,Preis,Region
|columns=1
|rowcolformat= style="background-color: transparent; width: 100%;"
|tablerow = %%,%%
|suppresserrors=true
}}

but at least, i have allways the Same problem. It shows me all what that NPC have, where example is in :\ The only what i want to see, is the Data for example >.< Someone knows how i can fix it? Yukii 11:34, 12 October 2011 (UTC)

Yukii11:34, 12 October 2011

You're looking for Extension talk:DynamicPageList (third-party). This talk page is about a different extension.

Bawolff23:25, 16 October 2011

Oh Sorry! Thanks for the Info! Yukii 12:48, 17 October 2011 (UTC)

Yukii12:48, 17 October 2011
 
 

Bug: Colon in category name returns no results

If there is a colon in the category name, produces no results. Thus:

<DynamicPageList>
category       = Foo: Bar
</DynamicPageList>

Will always fail.

Agrestis14:07, 19 September 2011
Edited by another user.
Last edit: 03:35, 21 September 2011

I could not reproduce this. The only time it failed was if the category was named something like category:project:foo, where the category started with another namespace (which was fixed in rev:97584).

Bawolff00:25, 20 September 2011
 

Hack: Add optional headings for lists

The following additions provide headings for any list that displays results. This can be useful since it avoids trying to test for results in a template (which is very difficult to do).

The following has been tested on the version of DPL which works with MW 1.16.

<?php
 
//etc...
        $sStartList = '<ul>';
        $sEndList = '</ul>';
        $sStartItem = '<li>';
        $sEndItem = '</li>';
 
        $sStartHead = '';
        $sEndHead = '';
        $sTextHead = '';
 
        $bUseGallery = false;
//etc....
 
                        case 'nofollow': # bug 6658
                         if ( 'false' != $sArg ) {
                                        $aLinkOptions['rel'] = 'nofollow';
                                }
                                break;
                        case 'headingtext':
                                $sTextHead = htmlspecialchars($sArg);
                                break;
                        case 'headingtag':
                                switch ($sArg)
                                {
                                case 'h2':
                                        $sStartHead = '<h2>';
                                        $sEndHead = '</h2>';
                                        break;
                                case 'h3':
                                        $sStartHead = '<h3>';
                                        $sEndHead = '</h3>';
                                        break;
                                case 'h4':
                                        $sStartHead = '<h4>';
                                        $sEndHead = '</h4>';
                                        break;
                                case 'h5':
                                        $sStartHead = '<h5>';
                                        $sEndHead = '</h5>';
                                        break;
                                case 'h6':
                                        $sStartHead = '<h6>';
                                        $sEndHead = '</h6>';
                                        break;
                                case 'br':
                                        $sStartHead = '<b>';
                                        $sEndHead = '</b><br />';
                                        break;
                                default:
                                        $sStartHead = '<b>';
                                        $sEndHead = '</b>';
                                        break;
                                }
                                break;                        
                } // end main switch()
 
//etc.....
 
        //start unordered list
        $output = $sStartHead.$sTextHead.$sEndHead.$sStartList . "\n";
 
//etc....
?>

This will provide headings for the ordinary lists, but not the gallery view.

The extra parameters are thus:

  • headingtext - Text to use as a heading if results are found.
  • headingtag - Tag to surround the heading text with. One of:
    • h2-h6 (headings 2 through 6)
    • b (bold)
    • br (bold followed by a br tag.

Example:

<DynamicPageList>
category    = Foo
headingtext = List of Foo
headingtag  = h2
</DynamicPageList>

Please note that the headings won't appear in the table of contents, regardless of which tag is used, but they will be formatted to appear laccording to the tag chosen.

Agrestis14:23, 19 September 2011

Bug: Incompatible with Variables Extension

If used with Extension:Variables any variables set before the call to DPL are cleared by the first DPC call that produces successful results. Thus:

{{#vardefine:foo|bar}}
{{#tag:DynamicPageList| category    = {{#var:foo}} }}
{{#tag:DynamicPageList| category    = {{#var:foo}} }}
{{#var:foo}}

The first DPL will produce the expected results, the second call will produce no results, and the attempt to print out the foo variable at the end will return empty.

The 3rd party extension seems to have had this same problem but have apparently now solved it.

Agrestis14:03, 19 September 2011

I consider this an Extension:VariablesExtension issue. It should make sure the clearState hook is being called for the parser object it's attached to. For example it is also incompatible with the categorytree extension when using the showcount="on" option. (A similar issue was recently fixed in cite in r89220)

(With that said, I suppose the way DynamicPageList calls Parser->transformMsg is kind of a bit odd...)

Bawolff00:56, 20 September 2011
 

Installation Question..

Edited by another user.
Last edit: 13:11, 31 August 2011

Why "include" not "require" (and why "include" not "include_once")? Just wondering as currently all the other extensions I have for Mediawiki 1.17 are invoked by require_once as apposed to include? Ashimema 13:11, 31 August 2011 (UTC)

86.10.117.17813:11, 31 August 2011

both do the same thing so it really doesn't matter. (Well actually require is slightly better as it makes a fatal instead of warning if you make a typo). I'll change it

Bawolff08:13, 1 September 2011

Cheers Bawolff.. that's clears it up somewhat for me. I knew they did roughly the same thing, just didn't know what the difference was and if it was important. Ashimema 08:27, 1 September 2011 (UTC)

Ashimema08:27, 1 September 2011
 
 

Bug? List of recently edited pages updated when talk pages are created

I use this extension to generate a list of recently edited pages within a certain namespace:

<DynamicPageList>
namespace = 102
count = 10
order = descending
redirects = exclude
shownamespace = false
addfirstcategorydate = false
mode = unordered
ordermethod = lastedit
</DynamicPageList>

However, when a discussion page in the associated TALK namespace (i.e. namespace 103) is created, the above list gets updated. Is there a way to avoid this?

--Dvd3141 05:02, 15 August 2011 (UTC)06:48, 25 August 2011

The ordermethod lastedit doesn't really order by last edit (thus is poorly named) but by the last time the cache for that page was purged (page_touched) (and thus is triggered by all sorts of things, like if a template included on that page is updated). At the moment there isn't really a work around for this extension.

Bawolff 03:30, 25 August 2011 (UTC)06:49, 25 August 2011
 

Is there a way to use a dynamic page list inside a template, where the category name is the template argument?

—The preceding unsigned comment was added by an unknown user on a unknown date.06:47, 25 August 2011

Yes. You just need to use #tag. For an example, see wikibooks:Template:CategoryIntersection.

Helder 19:09, 3 August 2011 (UTC)06:47, 25 August 2011

Thank you so much for your help. I'd been trying to use #tag but I was putting it in the wrong place, the example really helped. Thanks again.

—The preceding unsigned comment was added by an unknown user on a unknown date.06:48, 25 August 2011
 
 

addfirstcategorydate and ordermethod do not work on namespaces

This is a job for semantic mediawiki, but it doesn't work either! addfirstcategorydate and ordermethod only work on categories. It won't work for me on namespaces.

Badon 03:59, 12 July 2011 (UTC)06:46, 25 August 2011

I assume you mean if the query had a namespace clause but no category clauses? addfirstcategorydate needs a category to work with since it adds the date the page was added to the category. Ordermethod should work without a category clause, but some ordermethods (such as ordering by categoryadd) won't for obvious reasons. Which ordermethod isn't working for you?

Bawolff 03:34, 25 August 2011 (UTC)06:46, 25 August 2011
 

Feature request: hCalendar

As a lover of random microformats and an active Wikinewsie, I saw this and thought it might be a good candidate for the hCalendar microformat. It would siply have to output:

* <span class="vevent"><abbr class="dtstart" title="yyyy-mm-ddZ">d month yyyy</abbr>: <span class="summary">[[Title]]</span></span>

rather than just:

* d month yyyy: [[Title]]

Of course, this only works if it is set to output the date, and some styling of the abbr might be wanted to remove the border-bottom. I don't really feel strongly about this - I just ♥ microformats, and thought I'd suggest it.

Dendodge 01:09, 29 June 2011 (UTC)06:44, 25 August 2011

Hmm, is it a safe assumption that the date in a dpl list always refers to the start of an event? If you can find an actually live concrete example of someone some where who would benefit from the embeded microformat data, it would add a lot to this proposal. (As an aside, a user custom format might be added in the future which would allow the user to design any custom format they like).

Bawolff 03:17, 29 June 2011 (UTC)06:45, 25 August 2011

dtstart is simply the name given to the date parameter. For a duration, one would match it with dtend, but alone it simply marks the date and time at which something happened - in this case, the date the article was added to the category. This would come in useful to people who wanted an easy way to plot various events (e.g. on Wikinews) on a timeline or calendar - while now that would have to manually enter each date and event, this would allow them to simply export (e.g. using Operator) all the hCalendar events on a page, and import the resultant file into their application of choice, which is far easier. Use will, of course, be limited, but it's something some people might want to do (I have done similar things myself in the past, manually), and it has little-to-no impact on other users' experience, other than perhaps a millisecond increase in loading time. As support for hCalendar becomes more widespread, this will have more uses and applications.

Dendodge 12:15, 29 June 2011 (UTC)06:45, 25 August 2011
 
 

Only display articles starting with "f.eks"

Is it possible to only list articels starting with f.eks. A from a catagory?

—The preceding unsigned comment was added by an unknown user on a unknown date.06:43, 25 August 2011

Not with this extension. The third party dpl probably could.

Bawolff06:44, 25 August 2011
 

mode = 'inline', case add.( 모드가 인라인인 경우 추가 )

+++ DynamicPageList.php ( working )

@@  +188,6 @@
    case 'mode':
       switch ( $sArg ) {
+      case 'inline':
+           $sStartList = '<div>';
+           $sEndList = '</div>';
+           $sStartItem = '<span>';
+           $sEndItem = '</span>, ';
+           break;

—The preceding unsigned comment was added by an unknown user on a unknown date.06:42, 25 August 2011

Umm, why?

Bawolff 19:02, 15 April 2011 (UTC)06:42, 25 August 2011
 

gallery mode: images only?

The gallery mode is useful but it can't exclude other files than images. would an option to check for the mime type be too heavy?

--Subfader 20:48, 10 April 2011 (UTC)06:40, 25 August 2011

Compared to the other things this extension does, its probably would not be horrible. Just doing filter by mime type wouldn't really filter out all non-images since images can cover multiple mime types (although filtering by mime type is just as easy as doing show only stuff that is image/*, but that still brings up the question of what is an image. Is a pdf an image, it can be displayed as an image with a thumbnail. Is an xcf file an image? it certainly is, but files like File:Opampinstrumentation.xcf cannot be displayed as a thumbnail. (otoh, if you just want one specific type of image, the what is an image debate is kind of moot).

Bawolff 23:28, 10 April 2011 (UTC)06:40, 25 August 2011
 

Speed improvement by only using the recentchanges table

I'd like to see an option recentchanges=1 that would only check the recentchanges table. This would be helpful for simple lists like the latest pages of a certain namespace (not category) on high traffic pages like Main Page since the recentchanges table is very small. Most parameters would still work tho.

--Subfader 22:55, 5 February 2011 (UTC)06:39, 25 August 2011
First page
First page
Previous page
Previous page
Last page
Last page
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox