Extension talk:DynamicPageList (Wikimedia)
Contents
![]() First page |
![]() Previous page |
![]() Next page |
![]() Last page |
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?
I don't think that is possible with this extension.
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.
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.
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?
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.
This is expected behaviour (as a compromise between giving super up to date output and performance) See bugzilla:11685.
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",
<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;
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)
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
}}
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.
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)
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.
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)
You're looking for Extension talk:DynamicPageList (third-party). This talk page is about a different extension.
If there is a colon in the category name, produces no results. Thus:
<DynamicPageList> category = Foo: Bar </DynamicPageList>
Will always fail.
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).
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.
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.
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...)
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)
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?
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.
Is there a way to use a dynamic page list inside a template, where the category name is the template argument?
Yes. You just need to use #tag. For an example, see wikibooks:Template:CategoryIntersection.
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.
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?
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.
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).
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.
Is it possible to only list articels starting with f.eks. A from a catagory?
+++ DynamicPageList.php ( working )
@@ +188,6 @@
case 'mode':
switch ( $sArg ) {
+ case 'inline':
+ $sStartList = '<div>';
+ $sEndList = '</div>';
+ $sStartItem = '<span>';
+ $sEndItem = '</span>, ';
+ break;
Umm, why?
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?
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).
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.
![]() First page |
![]() Previous page |
![]() Next page |
![]() Last page |



