Jump to content

Extension talk:DynamicPageList

About this board


Previous page history was archived for backup purposes at Extension talk:DynamicPageList/LQT Archive 1 on 2015-07-10.

Exclude (parent) page

2
Tule-hog (talkcontribs)

Is there a way to automatically exclude the PrefixIndex of wherever the list is called to be excluded from the results?

E.g., say I am at Portal:Science/Related portals and I use the following:

<dynamicpagelist>
category=Science portals
namespace = Portal
</dynamicpagelist>

Is there a parameter to omit Portal:Science from the resulting list?

Bawolff (talkcontribs)

Not currently. At best you could add the current page to a category, and then use notcategory.

Reply to "Exclude (parent) page"

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

4
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.

Gryllida (talkcontribs)

I think 'notcategory' exists, no?

79.140.117.47 (talkcontribs)

maybe only maybe you should repeat the reading, no? --Gunnar.offel (talk) 10:42, 17 September 2024 (UTC)

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

Could we have pages ordered by actual last edit?

1
Solstag (talkcontribs)

Ni! Did anything change that would allow an 'ordermethod' that actually ranks pages by last edit, and not last touched? This would be very useful in WikiProjects or Wikiversities, for example, where displaying a summary of recently updated pages related to a specific wikiproject, educational project, or research project can be very useful. Cheers!

Reply to "Could we have pages ordered by actual last edit?"

Maximum number of results by date, not by quantity

3
Gryllida (talkcontribs)

Hi,

<DynamicPageList>
category=MyCategory
ordermethod=categoryadd
order=ascending
namespace=Main
</DynamicPageList>

How can I list results which were added to this category no more than 5 days ago? If it was more than 5 days ago, just don't show it.

Similarly 'only the results which were added 6 or more days ago' would be great to show.

Regards,

Gryllida (talkcontribs)
Bawolff (talkcontribs)

You cant

Reply to "Maximum number of results by date, not by quantity"

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"