If i try to list several pages that are in one category i can't exclude the ns_main page of this collection. an option like "notcategory" would be helpfull.
Extension talk:DynamicPageList (Wikimedia)
i generated an template that checks if namespacenumber equals 0 then set mainnamespace as category. So i found an solution, filter would be much more efficent.
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",
This post was posted by Odysseus277, but signed as 188.192.164.182.
Too bad this was never integrated, and, along the way, mysql_real_escape_string was seemingly removed.
After upgrading MediaWiki and DPL from 1.35 to 1.39 now I see an added category at the bottom of a page that uses DPL:
"Category: Pages using DynamicPageList"
Is there a way to disable this?
Change the page MediaWiki:intersection-category to be a single dash (See also the page Special:TrackingCategories on your wiki).
Alternatively, if you create the page 'Category:Pages using DynamicPageList' with the contents __HIDDENCAT__
the category will still be there but it won't show up on the main interface
👍Thanks!!!
Any chance to sort by that, like it is by default in a category list?
that is what the sortkey sort method does that you mentioned below.
For me it also does not sort alphabetically if i use
dynamicpagelist category = xy
ordermethod = sortkey
order = ascending
I used:
dynamicpagelist category = xy
ordermethod = sortkey
order = ascending
Page A has sortkey 1
Page B has sortkey 2
The list DPL spits out does not differentiate between A and B. It does show A on top of B, but there is no way to see that they are in a different sortkey group.
Any ideas?
it only supports ordering by sort key, not doing anything else by sortkey.
I'm using gallery mode with PageImages, and it's working great, I've hidden the file size, but under each image is the image's dimensions (i.e. "980 x 540") and I'm not seeing any obvious way to hide this. Is there a way to get gallery mode to show just the image and page title?
same problem, have you found a solution?
I found a workaround.
Add following code to your common.css
div.gallerytext > p { font-size: 1px !important; color: transparent !important; line-height: 1% !important }
div.gallerytext > p a { font-size: initial !important; line-height: initial !important; color: initial !important; }
worked for me.
https://whodat.dream13.com/Main_Page
xoxo
When i sort by
<DynamicPageList>
category = xy
addfirstcategorydate = true
ordermethod = created
</DynamicPageList>
It also displays the date, which can be useful but is there any way to hide that?
It then looks like this
- 19. März 2021: xyz
remove the "addfirstcategorydate" line.
Hi!
Cannot understand how to restrict showing files in category (Media files). I see that there are files in list that has been uploaded to the category. So how to make so, that files are not shown in my list?
Thank you!
How often generated lists are updated?
New pages added to category, but if I do not edit and save page containing the list it is not updated.
How update can be forced?
Hello everyone,
Could you please let me know how can I set a list showing recently created pages at my wiki? Thank you!