Issue:Select discussion by category of talk page
Description: | select discussion pages based on the category of their underlying article |
Extension / Version: | DPL / ? |
Type / Status: | Feature / answered |
Feature
Objective: show latest changes to discussions about articles having a category. The discussion page should not need to have a category assigned. I made a quick hack to do that: (sametitlenamespace is unused)
diff -ru DynamicPageList-1.5.2/DynamicPageList2.php DynamicPageList-1.5.2-mjs/DynamicPageList2.php --- DynamicPageList-1.5.2/DynamicPageList2.php 2007-11-02 19:58:06.000000000 +0100 +++ DynamicPageList-1.5.2-mjs/DynamicPageList2.php 2007-11-08 13:10:41.000000000 +0100 @@ -226,7 +226,7 @@ * offset and count are now implemented directly in SQL */ -define('DPL2_VERSION', '1.5.2'); // current version +define('DPL2_VERSION', '1.5.2+mjs'); // current version @@ -680,7 +680,15 @@ * Empty value (default) means no limit. * Not applicable to mode=category. */ - 'titlemaxlength' => array('default' => '', 'pattern' => '/^\d*$/') + 'titlemaxlength' => array('default' => '', 'pattern' => '/^\d*$/'), + + /** + * search for a page with the same title in another namespace (this is normally the article to a talk page) + */ + 'sametitlecategory' => NULL, + 'sametitlenamespace' => NULL + + ); /** @@ -1124,6 +1132,8 @@ $aNamespaces = array(); $aExcludeNamespaces = array(); + + $sSameTitleCategory = null; // Output $output = ''; @@ -1867,6 +1877,9 @@ case 'oneresultfooter': $sOneResultFooter = $sArg; break; + case 'sametitlecategory': + $sSameTitleCategory = $sArg; + break; /** * DEBUG, RESET and CACHE PARAMETER @@ -2549,6 +2562,15 @@ // page_id=pl.pl_from (if pagelinks table required) $sSqlWhere .= $sSqlCond_page_pl; + + if ( isset($sSameTitleCategory) && $sSameTitleCategory !== null ) { + $sSqlWhere .= " AND $sPageTable.page_title IN ( + select p2.page_title + from $sPageTable p2 + inner join $sCategorylinksTable clstc ON (clstc.cl_from = p2.page_id AND clstc.cl_to = ".$dbr->addQuotes($sSameTitleCategory)." ) + where p2.page_namespace = 0 + ) "; + } // GROUP BY ... if ($sSqlGroupBy!='') {
--mjs 15:01, 8 November 2007 (CET)
Reply
That´s a good idea. I tend to add a new parameter named 'articlecategory' (as we set the namespace of the join target always to 0). I think this is the most probable use for such a feature. One could then write something like
namespace=Talk articlecategory=Test
which looks quite well readable ...
Another way to achieve the same thing would be to change the target namespace. i.e. apply all kinds of selection criteria to the base page (article page) but to deliver the talk page. In that case we could have a keyword like 'returnnamespace' which could be set to "Talk".
The first solution has the advantage that you can apply criteria to the discussion page itself in the normal way AND define the category of the underlying article at the same time. Although the only restriction one can apply is just one category ...
- Gero 11:58, 9 November 2007 (CET)