Extension talk:DynamicPageList (Wikimedia)

About this board

Archives 

/Archive 01 - /Archive 02


"notnamespace" analog to "notcategory" to exclude namespaces (NS_Main) for example

2
Gunnar.offel (talkcontribs)

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.

Gunnar.offel (talkcontribs)

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.

Reply to ""notnamespace" analog to "notcategory" to exclude namespaces (NS_Main) for example"

New feature parameter: categorymatch

2
Odysseus277 (talkcontribs)

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.

76.102.130.155 (talkcontribs)

Too bad this was never integrated, and, along the way, mysql_real_escape_string was seemingly removed.

Reply to "New feature parameter: categorymatch"

"Category: Pages using DynamicPageList"

3
95.19.255.159 (talkcontribs)

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?

Bawolff (talkcontribs)

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

95.19.255.159 (talkcontribs)

👍Thanks!!!

Reply to ""Category: Pages using DynamicPageList""
Bedtry (talkcontribs)

Any chance to sort by that, like it is by default in a category list?

Bawolff (talkcontribs)

that is what the sortkey sort method does that you mentioned below.

2003:D0:170C:1B59:4D2:D048:FC91:AB0C (talkcontribs)

For me it also does not sort alphabetically if i use

dynamicpagelist category = xy

ordermethod = sortkey

order = ascending

Reply to "Sort alphabetically?"

If sorted by sortkey, list should follow that

2
Bedtry (talkcontribs)

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?

Bawolff (talkcontribs)

it only supports ordering by sort key, not doing anything else by sortkey.

Reply to "If sorted by sortkey, list should follow that"

Hide image dimensions in gallery mode?

4
Neilan (talkcontribs)

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?

86.219.236.74 (talkcontribs)

same problem, have you found a solution?

Pd4u (talkcontribs)

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; }

Rhonda1311 (talkcontribs)
Reply to "Hide image dimensions in gallery mode?"
Bedtry (talkcontribs)

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?

Bedtry (talkcontribs)

It then looks like this

  • 19. März 2021: xyz
Mshastchi (talkcontribs)

remove the "addfirstcategorydate" line.

Reply to "Hide dates"
Fokebox (talkcontribs)

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!

Reply to "Notcategory"
Fidoman (talkcontribs)

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?

Reply to "Updating list"

Show new created pages list

1
Summary by Fokebox

Found solution below

Fokebox (talkcontribs)

Hello everyone,

Could you please let me know how can I set a list showing recently created pages at my wiki? Thank you!