Difference between revisions of "DPL:FAQ"
(40 intermediate revisions by 13 users not shown) | |||
Line 1: | Line 1: | ||
__TOC__ __NEWSECTIONLINK__ | __TOC__ __NEWSECTIONLINK__ | ||
+ | ==Duplicating page TOC== | ||
+ | Any tips for using this extension to duplicate a page's TOC? --[[User:Two7s clash|Two7s clash]] 17:36, 17 April 2010 (UTC) | ||
+ | :No , I never came across that requirement. Why would one wish to do that? [[User:Gero|Gero]] 20:57, 18 April 2010 (UTC) | ||
+ | |||
+ | :I want to be able to duplicate a TOC in the sidebar, using DPL and TreeAndMenu. I was hoping I could use DPL to generate a list of TOC links per page that could be picked-up by TreeAndMenu and to generate a dynamic master TOC. I'm using Mediawiki to present a book. --[[User:Two7s clash|Two7s clash]] 00:29, 20 April 2010 (UTC) | ||
== Using conditions within DPL table == | == Using conditions within DPL table == | ||
Line 113: | Line 118: | ||
<pre><dpl> | <pre><dpl> | ||
uses = Template:Todo2 | uses = Template:Todo2 | ||
− | include = {Todo2}:1 | + | include = {Todo2}:1:2 |
includematch= /\|(Sam Brown)|(Brown)|(SBrown)/i | includematch= /\|(Sam Brown)|(Brown)|(SBrown)/i | ||
table = ,,Person,Task | table = ,,Person,Task | ||
Line 120: | Line 125: | ||
<dpl> | <dpl> | ||
uses = Template:Todo2 | uses = Template:Todo2 | ||
− | include = {Todo2}:1 | + | include = {Todo2}:1:2 |
includematch= /\|(Sam Brown)|(Brown)|(SBrown)/i | includematch= /\|(Sam Brown)|(Brown)|(SBrown)/i | ||
table = ,,Person,Task | table = ,,Person,Task | ||
Line 870: | Line 875: | ||
:[[User:Japher|Japher]] 15:50, 17 December 2009 (UTC) | :[[User:Japher|Japher]] 15:50, 17 December 2009 (UTC) | ||
− | + | ===Response=== | |
+ | The easiest way to achieve this is to explicitly remove the trailing separator by a #dplreplace statement. The following statement shows how to do it: | ||
<pre><nowiki> | <pre><nowiki> | ||
Line 890: | Line 896: | ||
}}|/ • $/|}} | }}|/ • $/|}} | ||
− | + | --[[User:Gero|Gero]] 08:48, 20 December 2009 (UTC) | |
+ | |||
+ | ::Excellent, thanks Gero! --[[User:Japher|Japher]] 17:03, 6 January 2010 (UTC) | ||
+ | |||
+ | ::Gero, I don't have dplreplace, and I notice that is only recently include in DPL v1.9.0. Is there any way that I can get this version? The most recent version I can find seems to be v1.8.9. Is v1.9.0 released yet? --[[User:Japher|Japher]] 14:25, 12 January 2010 (UTC) | ||
+ | |||
+ | :::Japher, just use the #replace function that comes as part of the [[Download]] within the ''StringFunctions''. The #dplreplace is only a copy of that function which I will incoroprate4 into the next release to reduce cross-extension dependencies. -- [[User:Gero|Gero]] 10:06, 30 January 2010 (UTC) | ||
− | ::: | + | ::::An easier way is to just set inlinetext ''after'' the format parameter. |
+ | <DPL> | ||
+ | category=cities | ||
+ | format = ::::,''[[%PAGE%|%TITLE%]]'' ,, | ||
+ | inlinetext = --- | ||
+ | </DPL> | ||
− | ::: | + | ::::Notice the difference when you put it ''above'' the format parameter: |
+ | <DPL> | ||
+ | category=cities | ||
+ | inlinetext = --- | ||
+ | format = ::::,''[[%PAGE%|%TITLE%]]'' ,, | ||
+ | </DPL> | ||
+ | ::::This is one of the things I very much like. --[[User:Sandman|Sandman]] 11:19, 30 January 2010 (UTC) | ||
== Best way to return list of new pages == | == Best way to return list of new pages == | ||
Line 920: | Line 943: | ||
You use debug=3 to get the SQL statement. You paste that statement into phpmyadmin and check its run time. Then you try to optimise the SQL statement. If you come up with a version that runs considerably faster, you leave a message here with both SQL statements (maybe you could mark the difference if it is not obvious). Then I can check the effort to teach DPL to use that "shortcut" under certain circumstances (i.e. if the DPL query does not contain other conditions which make it necessary to touch the articles table). O.k. ? --[[User:Gero|Gero]] 00:21, 14 January 2010 (UTC) | You use debug=3 to get the SQL statement. You paste that statement into phpmyadmin and check its run time. Then you try to optimise the SQL statement. If you come up with a version that runs considerably faster, you leave a message here with both SQL statements (maybe you could mark the difference if it is not obvious). Then I can check the effort to teach DPL to use that "shortcut" under certain circumstances (i.e. if the DPL query does not contain other conditions which make it necessary to touch the articles table). O.k. ? --[[User:Gero|Gero]] 00:21, 14 January 2010 (UTC) | ||
+ | |||
+ | :Oh noes! Lost my reply I actually thought I posted back then. I didn't mean that it should be included and I understand that DPL shouldn't grow much more. | ||
+ | :I made some tests and I couldn't speed it up. on localhost (~1000 pages) the speed was fast enough, but on the server (26k articles) it varied between 0.3 and 0.5 seconds, which quite slow. | ||
+ | :I just thought the Recent Changes table would enable faster and nice queries like "Recently created arcticles", or even pages created today or in the past 24 hours. --Subfader 15:01, 17 January 2010 (UTC) | ||
+ | |||
+ | == Return real %TOTALPAGES% while using DPL_fromTitle == | ||
+ | |||
+ | %TOTALPAGES% reads the number of pages left when DPL_fromTitle is used. But it should return what it is ment to return: the total number of results for a DPL query.<br>Background: If you want to use a template of fixed "jump to" marks you can't return the number of total pages found with the query. I guess the reason is that scrolling is a new query each time? | ||
+ | |||
+ | I'd like to use DPL to replace the page section on category pages. As example see [[User:Subfader/JumpTo]] (using &DPL_fromTitle=...) vs [[:Category:Events]] (using MW's &from=...). On The category navigation, note how the total stays the same and navigating back is possible. | ||
+ | |||
+ | So how could %TOTALPAGES% be properly used in let's say [[DPL Example 027]]?<br>If this shouldn't be possible, how to navigate through results as in [[:Category:Events]] other than with DPL_fromTitle? --[[User:Subfader|Subfader]] 00:36, 16 January 2010 (UTC) | ||
+ | |||
+ | === Repsonse === | ||
+ | The simplest way would be a second query which does not produce any output except the number of total pages. This sounds bad in terms of performance but maybe DPL could be taught to skip any processing of page titles if something like "format=," were given. Currently it will go through all pages and do nothing with them (which means a SQL FETCH without any need). Ideally you would want to see a SQL statement which only cointains a SELECT COUNT .. FROM ..."). | ||
+ | I suspect, however, that performance overhead is not too big in many cases, so I recommend to try the simple approach of a dedicated "counter query" first. | ||
+ | |||
+ | <nowiki> Example: {{#dpl:category=Events|format=,|resultsheader=There are %TOTALPAGES% events in total.}}. </nowiki> | ||
+ | |||
+ | Example: {{#dpl:category=Events|format=,|resultsheader=There are %TOTALPAGES% events in total.}}. | ||
+ | |||
+ | --[[User:Gero|Gero]] 22:15, 17 January 2010 (UTC) | ||
+ | |||
+ | :That would be an option yeah. But it [[User:Subfader/JumpTo/2|doesn't seem work]] and doesn't solve the odd navigation problem when DPL_fromTitle is used. Looks like I better don't replace category page lists with DPL. Thanks though! --[[User:Subfader|Subfader]] 23:23, 17 January 2010 (UTC) | ||
+ | |||
+ | |||
+ | == Summary Tables == | ||
+ | |||
+ | Hello, I'm new to using wikis. I want to product tables such as the [http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Mathematics/Wikipedia_1.0 Math Project Summary Tables]. I understand how I can use templates and variables to output a list of all the topics showing their priority and their quality. This would be a very big table and not very useful. I don't understand how to go from that simple table to a summary where one variable is compared to another. Could you give an examples? Thanks! [[User:Mrnlvr13|Mrnlvr13]] 17:16, 22 February 2010 (UTC) | ||
+ | |||
+ | == Multiple includes in one table cell == | ||
+ | |||
+ | Hi, | ||
+ | |||
+ | I am trying to get multiple items from an Include call to display in one table cell. | ||
+ | |||
+ | Here is my dpl | ||
+ | <pre> | ||
+ | {{#dpl: | ||
+ | |uses=Template:Server | ||
+ | |notuses=Template:Retired | ||
+ | |nottitlematch=Server | ||
+ | |include={Server}:InService:Type:OS:Func1:Func2:Func3 | ||
+ | |mode=userformat | ||
+ | |table=class="sortable",Name,In Service,Type,OS,Func1,Func2,Func3 | ||
+ | }} | ||
+ | </pre> | ||
+ | |||
+ | What I want is Func1, Func2 and Func3 to be displayed as an unordered list in one table cell. Is this possible? The above example gives a column for each Func. I played with tablerow, but couldn't work it out, and really wanted to use format, but found the documentation a bit tricky/incomplete for me. | ||
+ | |||
+ | Thanks! [[User:JonathanKing|JonathanKing]] 00:08, 1 March 2010 (UTC) | ||
+ | |||
+ | ::You should use a phantom template. The [[format]] statement defines the outer frame of the result table and the cell(s) are filled within the phantom template. Within the wiki source of the phantom template you can write wiki code to put arbitrary fields into one or more table cells. There are lots of examples here in this wiki how to use phantom templates. See the docs on [[include]]. [[User:Gero|Gero]] 21:44, 2 March 2010 (UTC) | ||
+ | |||
+ | == Return user and date of page creation == | ||
+ | There are %USER% and %DATE% as [[Format#format|format options]]. The example mentions lastedit. Does that mean to return a list of new pages reading "Page - created by User on Date", you would have to add ordermethod=firstedit and the %USER% and %DATE% are automatically returning those dates instead of lastedit? --[[User:Subfader|Subfader]] 12:11, 12 May 2010 (UTC) | ||
+ | |||
+ | :Indeed, that is what should happen by some magic ;-) [[User:Gero|Gero]] 18:30, 14 May 2010 (UTC) | ||
+ | |||
+ | ::Yeah, noted that afterwards. It's awesome. Not too obvious from the [[Format#format|format options]] tho. --[[User:Subfader|Subfader]] 19:26, 14 May 2010 (UTC) | ||
+ | |||
+ | == Show thumbnails for all images on a page == | ||
+ | <pre> | ||
+ | {{#dpl: | ||
+ | |imagecontainer={{FULLPAGENAME}} | ||
+ | |format=,:[[Image:%TITLE%|thumb|150px|Image: %PAGE%|%TITLE%]]\n,, | ||
+ | }} | ||
+ | </pre> | ||
+ | |||
+ | It seems to work sometimes and not at others when it returns no data in the main namespace. Any thoughts? | ||
+ | |||
+ | == include and ParserBeforeStrip hook == | ||
+ | |||
+ | In my LocalSettings.php I have a function to replace article text before it is parsed. This function uses [http://www.mediawiki.org/wiki/Manual:Hooks/ParserBeforeStrip ParserBeforeStrip hook].<br>But the text is not parsed when I include article sections using [[Include#include|include]].<br>How can I solve this? ParserBeforeStrip seems to be the only working hook for me tho. Either the content displayed via include is not sent to ParserBeforeStrip, or can I send the content to my function changing DPL? Assitenace on this would be appreciated --[[User:Subfader|Subfader]] 13:15, 20 June 2010 (UTC) | ||
+ | |||
+ | :Nevermind, solved by adding a new hook. --[[User:Subfader|Subfader]] 16:17, 23 June 2010 (UTC) | ||
+ | |||
+ | ==Playing with Template Parameters== | ||
+ | Im creating a glossary and achieved to call the parameters into a table | ||
+ | |namespace=Glossar | ||
+ | |include= {Glossareintrag}:kanji:romaji:text:link | ||
+ | ... | ||
+ | | tablerow =class="jap"¦%%,%%,%%,<nowiki>[[%%]]</nowiki> | ||
+ | |||
+ | What I would like to do is to play a bit with the results and get something like... | ||
+ | <nowiki>[[link|text]]</nowiki> | ||
+ | ...as a result. Also I would like to ask, whether %% is empty or not and handle the result accordingly. Is there any way to do that? | ||
+ | --[[User:Bescheid|Bescheid]] 21:33, 30 July 2010 (UTC) | ||
+ | |||
+ | ::Read the manual and understand the concept of phantom (surrogate) templates. All you want to do can be´done with that technique ... 16:37, 31 July 2010 (UTC) | ||
+ | |||
+ | :::OK, I'll give it another try... Thx, [[User:Bescheid|Bescheid]] 20:40, 2 August 2010 (UTC) | ||
+ | |||
+ | ==Selective Data from Table== | ||
+ | I have a table on a page. It's easy enough to duplicate that table on another page.. | ||
+ | <pre> | ||
+ | |<DPL> | ||
+ | | titlematch = foo/bar/page/page | ||
+ | | namespace = | ||
+ | | mode = userformat | ||
+ | | includepage = #My Table | ||
+ | |</DPL> | ||
+ | </pre> | ||
+ | Is it possible to selectively grab columns from that table? For example, if this table has 6 columns, labeled col1, col2... can I grab just col1 and col6? | ||
+ | It would look something like this... | ||
+ | <pre> | ||
+ | |<DPL> | ||
+ | | titlematch = foo/bar/page/page | ||
+ | | namespace = | ||
+ | | mode = userformat | ||
+ | | includepage = #My Table | ||
+ | | include = #col1,#col6 | ||
+ | |</DPL> | ||
+ | </pre> | ||
+ | This doesn't work, of course, but hopefully you understand what I'm looking for. Thanks in advance! | ||
+ | :You could apply a regular expression to the content of the paragraph by using ²{#replace: .....}² in the format statement. This should work. You have to use the #replace parser function that comes with the "StringFunctions" in the DPL distribution. | ||
+ | :The regexp will be applied to the included wiki text portion. As this is a table you will have many pipe symbols in it. Special escaping is needed in that case (see regexp syntax for php). | ||
+ | :I very much recommend another approach: Create the original table by calling a TEMPLATE for each row. Then it is very easy and straight forward with DPL to extract whatever column(s) you want in a second wiki page. | ||
+ | :[[User:Gero|Gero]] 11:04, 5 January 2011 (UTC) | ||
+ | |||
+ | |||
+ | ==Limits to DPL queries?== | ||
+ | I am trying to use DPL to find all pages linking to some page. Using the Translate extension means our links must use a special format that is not recognized by the ordinary WhatLinksHere page or similar. I came up with this solution (here trying to find all pages containing the link <nowiki>[[Special:MyLanguage/Getting Help]]</nowiki> or the old style link <nowiki>[[Getting Help]]</nowiki>): | ||
+ | <pre> | ||
+ | |<DPL> | ||
+ | | namespace=Main |User | ||
+ | | nottitleregexp = .*(/..(-..)?|_[(].*[)])$ | ||
+ | | include = * | ||
+ | | includematch = #\[\[[Ss]pecial\:[mM]y[lL]anguage/Getting[_ ]Help|\[\[Getting[_ ]Help# | ||
+ | | includemaxlength = 0 | ||
+ | | resultsheader = The pages in the translation system linking to Getting Help are:\n | ||
+ | | format = ,\n* [[%PAGE%|%TITLE%]],, | ||
+ | |</DPL> | ||
+ | </pre> | ||
+ | This seems do do what I intended, but doesn't find all pages containing the text. I have experimented a bit, and find that when I narrow the search (fx searching only the Main namespace) I typically find more pages than with a broarder search. This leads me to suspect that I am having some sort of capacity problem. Since the results are very reproducible I wonder whether the query proceeds until some fixed capacity is exceeded. According to the sysadmins, however, there are no traces of any error messages in the logs. Is there a solution to this problem, or can I achieve my desired result with a more clever query? | ||
+ | [[User:Claus chr|Claus chr]] 12:23, 7 August 2012 (CEST) | ||
+ | :That is due to the parameter "includematch" and the limit to dpl queries. | ||
+ | :#"includematch" does not exactly work as a "page selection" parameter (like for example "category" or "titlematch"); includematch only "hides" all those found statements, that do not include the specified statement. Example: You search for all pages that link to [[WAZZUP]] and that contain the word "Hey"; say there are 800 pages that link to [[WAZZUP]], then your dpl query will only get the first 500 (see limit in next paragraph) and then checks these 500 results against the "includematch = hey" statement; all of those 500 pages without a "hey" will then be omitted (hidden) from the final result. The problem is, that the other 300 pages (after the first 500 ones) were not found in the initial query and therefore will not show up, even if they contain "hey". | ||
+ | :#Any DPL query is limited to a max of 500 results (unless you changed that in the settings); usually the parameter "count = xxx" allows you to increase that, but sometimes it doesn't work and you have to split your dpl call into several ones. | ||
+ | :My suggestion is that you split your dpl call in some way (maybe "titlematch = A%", "titlematch = B%", ...), so that each of these calls only contains at most 500 results (irregardless of the "includematch" statement). Then arrange all those different dpl queries in one neat table (you should use the parser function method <nowiki>{{#dpl: }}</nowiki> for these split up statements though). | ||
+ | :--[[User:Theaitetos|Theaitetos]] 17:35, 9 August 2012 (CEST) | ||
+ | ::Thank a lot for your answer. Unfortunately your suggestion is not going to work very well for us. If we can't filter on namespaces we are going to end up with an insane number of pages. In the main namespace we have about 1000 pages in English and about 2500 translated pages; but in the translation namespace there are on the order of 100000 pages (the way the translate extension works, each translated section gets its own page in that namespace). We'll try to increase the limit and hope our server can handle that. At any rate your explanation of what goes on is very useful. | ||
+ | ::[[User:Claus chr|Claus chr]] 18:02, 11 August 2012 (CEST) | ||
+ | :::Not sure what you mean, but filtering for namespaces does not pose a problem. Just write your dpl query the way you want and then split it up; example with our call from above: | ||
+ | <pre> | ||
+ | |<DPL> | ||
+ | | namespace=Main |User | ||
+ | | nottitleregexp = .*(/..(-..)?|_[(].*[)])$ | ||
+ | | include = * | ||
+ | | includematch = #\[\[[Ss]pecial\:[mM]y[lL]anguage/Getting[_ ]Help|\[\[Getting[_ ]Help# | ||
+ | | includemaxlength = 0 | ||
+ | | resultsheader = The pages in the translation system linking to Getting Help are:\n | ||
+ | | format = ,\n* [[%PAGE%|%TITLE%]],, | ||
+ | |</DPL> | ||
+ | </pre> | ||
+ | :::Split into: | ||
+ | <pre> | ||
+ | |<DPL> | ||
+ | | namespace=Main |User | ||
+ | | nottitleregexp = .*(/..(-..)?|_[(].*[)])$ | ||
+ | | include = * | ||
+ | | includematch = #\[\[[Ss]pecial\:[mM]y[lL]anguage/Getting[_ ]Help|\[\[Getting[_ ]Help# | ||
+ | | includemaxlength = 0 | ||
+ | | resultsheader = The pages in the translation system linking to Getting Help are:\n | ||
+ | | format = ,\n* [[%PAGE%|%TITLE%]],, | ||
+ | | titlematch = A%|B%|C%|D%|E%|F%|G%|H%|I%|J%|K%|L%|M%|N% | ||
+ | |</DPL> | ||
+ | |<DPL> | ||
+ | | namespace=Main |User | ||
+ | | nottitleregexp = .*(/..(-..)?|_[(].*[)])$ | ||
+ | | include = * | ||
+ | | includematch = #\[\[[Ss]pecial\:[mM]y[lL]anguage/Getting[_ ]Help|\[\[Getting[_ ]Help# | ||
+ | | includemaxlength = 0 | ||
+ | | resultsheader = The pages in the translation system linking to Getting Help are:\n | ||
+ | | format = ,\n* [[%PAGE%|%TITLE%]],, | ||
+ | | titlematch = O%|P%|Q%|R%|S%|T%|U%|V%|W%|X%|Y%|Z% | ||
+ | |</DPL> | ||
+ | </pre> | ||
+ | :::--[[User:Theaitetos|Theaitetos]] 21:03, 11 August 2012 (CEST) | ||
+ | ::::Thanks for this clarification. I had understood your original reply to imply that filtering on namespaces would be off when titlematch is use - rereading the reply I have no idea what made me think so. Combining filtering on namespaces and titles would indeed be possible. With a total of 3500 pages (and counting) in main namespace alone I still hope we can solve the problem by raising the limit on searched pages, though :-). | ||
+ | ::::[[User:Claus chr|Claus chr]] 16:50, 17 August 2012 (CEST) |
Latest revision as of 21:05, 17 August 2012
Contents
- 1 Duplicating page TOC
- 2 Using conditions within DPL table
- 3 I want to create a "Category Cloud." How do I change the font size based on the number of articles for a category?
- 4 My article name contains underscores, but in the DPL result they won´t appear.
- 5 When I use multi-column output my background color is cluttered
- 6 When I write a "What links here" DPL query, redirections are ignored
- 7 Getting pages with references to templates with particular parameters
- 8 Inserting spaces and comma in the output
- 9 I want the article list separated by comma
- 10 Why does my deleted page still appear on Special:Wantedpages?
- 11 Why does my deleted page still have a link to a query page in its What Links Here list?
- 12 How do I 'see' the wikitext my DPL generates?
- 13 How do I offset an ordered list by a certain number?
- 14 Can DPL improve the MediaWiki search dialogue?
- 15 How do I create tabular output?
- 16 I try to generate table formatting with DPL but it looks weird - to hell with the syntax!
- 17 Where can I talk about DPL?
- 18 Using multiple categories with phantom template
- 19 Can DPL be used to post text based on category of current page?
- 20 How would I code a DPL tag be used to post a category list of when the article was created/updated for the current month
- 21 I need to use a comma in my regexp but DPL uses the comma as a separator ..
- 22 Can DPL be used to create statistics per user?
- 23 Can DPL be used to create a subcategory listing with articles listed under their category
- 24 My templates suddenly breaks
- 25 How do you reference include parameters in a format statement?
- 26 Sorting by the value of a template parameter?
- 27 Using DEFAULTSORT or other sort key to order results
- 28 Random pieces of one page
- 29 url/dynamic
- 30 How do you reference include parameters in a format/tablerow statement into a template?
- 31 All articles that transclude from the main namespace?
- 32 tablesortcol ignoring identical values?
- 33 includematch
- 34 Selection by MIME types?
- 35 Last edits which are not page creations?
- 36 [RESOLVED] Include: Exclude category tags
- 37 Upcoming cache mechanism
- 38 Displaying subcategories like the default in wiki
- 39 Pages with DPL code should not "use" the results or "link from" them
- 40 linkstoexternal
- 41 How do I select pages with numeric parameters?
- 42 Define DPL Cache time period?
- 43 Article with response to DPLs query produces high load
- 44 Specifying colors to DPL table cells
- 45 Include and parser extension calls with parameters
- 46 Using Extension:UserFunctions as a parameter
- 47 Error setting up DPL
- 48 uses foo AND bar?
- 49 find pages that contain certain text
- 50 How can I have a separator like inlinetext when I'm using mode=userformat?
- 51 Best way to return list of new pages
- 52 Return real %TOTALPAGES% while using DPL_fromTitle
- 53 Summary Tables
- 54 Multiple includes in one table cell
- 55 Return user and date of page creation
- 56 Show thumbnails for all images on a page
- 57 include and ParserBeforeStrip hook
- 58 Playing with Template Parameters
- 59 Selective Data from Table
- 60 Limits to DPL queries?
Duplicating page TOC
Any tips for using this extension to duplicate a page's TOC? --Two7s clash 17:36, 17 April 2010 (UTC)
- No , I never came across that requirement. Why would one wish to do that? Gero 20:57, 18 April 2010 (UTC)
- I want to be able to duplicate a TOC in the sidebar, using DPL and TreeAndMenu. I was hoping I could use DPL to generate a list of TOC links per page that could be picked-up by TreeAndMenu and to generate a dynamic master TOC. I'm using Mediawiki to present a book. --Two7s clash 00:29, 20 April 2010 (UTC)
Using conditions within DPL table
I have the following code:
<dpl> category= *Camera include = {rating info}:camera table =class="wikitable sortable" border=2 cellpadding=2,UserID,Rating tablerow =align=middle bgcolor=#eeffee¦%%, bgcolor=#ffdddd¦%% </dpl>
Right now it prints out a table of users and their ratings about a product (the camera). I wish to add the feature such that if the rating is say equal to +2, then the background color for that particular user block changes according to the rating value. So if the rating is equal to -2 for another user, then the background color for that user block within the table is of a different color.
Thanks!! Casshyr 22:12, 4 June 2009 (UTC)
- See DPL Example 003 ! Gero 09:08, 5 June 2009 (UTC)
- http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions --Subfader 04:37, 5 June 2009 (UTC)
Tha
Warning: Parameter 1 to Language::getMagic() expected to be a reference, value given in C:\xampp\htdocs\mw\includes\StubObject.php on line 58
Warning: Parameter 3 to ExtDynamicPageList::dplTag() expected to be a reference, value given in C:\xampp\htdocs\mw\includes\parser\Parser.php on line 3323
Warning: Parameter 3 to ExtDynamicPageList::dplTag() expected to be a reference, value given in C:\xampp\htdocs\mw\includes\parser\Parser.php on line 3323nks for the example Gero! However, it still isn't working on my own mediaWiki...I even tried fooling around with the example and it works over there but not on my server.
<dpl> category=camera include={rating info}:camera table=,UserID,Rating tablerow=align=right ²{#if:²{#pos:%%¦133}²¦bgcolor=#ff9999 ¦bgcolor=#ffffaa}²|%% </dpl>
I basically use the exact same code as the example, and it doesn't work on mine. What could I be missing something? (i do have the parser extensions v1.1.1 installed for mediaWiki v1.14) Casshyr
- Thanks! It works now!! Casshyr
I want to create a "Category Cloud." How do I change the font size based on the number of articles for a category?
You have to use one dpl query to select a list of suitable categories. Within the format statement of that query you call another query (in a separate template) which calculates the number of members for each category. This template uses #expr to calculate the font-size. Make sure to use an advanced version of ParserFunctions extension which really understands "floor" and "sqrt".
For an example see Test category cloud.
Thank you! I really appreciate your help. Your programming is awesome. (BTW, following your advice, I needed the extended parser functions). This is a great way of quickly "seeing" a large number of articles. -Jim Miller
My article name contains underscores, but in the DPL result they won´t appear.
Normally, DPL replaces all undercores in article names by spaces when showing the result. You can replace underscores by their symbolic html name via the 'replaceintitle' statement. So DPL will no longer recognize the underscores and later the html engine will translate the symbolic name to underscores.
This wiki contains an Article_with_underscore. Normally DPL would show it as . But with {{#dpl:titlematch=%underscore|replaceintitle=/ /,_}} you will getWhen I use multi-column output my background color is cluttered
There is a special parameter named rowcolformat which allows to set the background color, cell-spacing etc. in combinaton with 'columns=' or 'rows='. See also DPL:Requests_for_new_features_Archive#Global background-color.
When I write a "What links here" DPL query, redirections are ignored
Say you have an Article A1 which links to B and an Article A2 which links to B2. But B2 is redirected to B.
{{#Wgraph: name=FAQ1 | png | thumb=50 |
node A1 {color=green} node A2 {color=green} node B {color=red} node B2 {color yellow} edge A1 B {} edge A2 B2 {} edge B2 B {label = #REDIRECT } orientation = left_to_right
}}
A standard DPL query using
linksto = B
will only deliver Article A1 because the default is to ignore #redirects.
redirects = include linksto = B
will give you Article A1 and B2 as B2 redirects to B. But this may not be what you want. You still won´t get A2 as it links to B2 and not to B. The trick is to get the direct links to B in the normal way and to use a nested subquery which finds the pages which link to pages that redirect to B. We write the query in a way that it accepts the name of the target page (B) as a parameter:
Template:LinksToWithRedirect ---------------------------- {{#dpl: |linksto={{{1}}} }} {{#dpl: |linksto={{{1}}} |redirects=only |format=,²{LinksTo¦%PAGE%}², }} Template:LinksTo ---------------- {{#dpl: |debug=1 |linksto={{{1}}} |format=,*[[%PAGE%¦%TITLE%]]\n, }}
Now calling {{LinksToWithRedirect|B}} will return A1 and A2.
See also Listing Redirects and Location
Getting pages with references to templates with particular parameters
With DPL you can find all pages which use a certain template. You can specify that you only want to see those articles where a ceratin parameter of that template has a certain value. You can even allow for a group of values if you use the power of regular expression as the following examples shows:
Let's say that your company uses a wiki to assign and keep track of tasks. So, let's say that you have created a todo template which, as a parameter, takes the name, username, or some other semblance of a name of a person responsible for the task. If you now want to see the tasks which have been assigned to a given person you could use something like
<dpl> uses = Template:Todo2 include = {Todo2}:1:2 includematch= /\|(Sam Brown)|(Brown)|(SBrown)/i table = ,,Person,Task </dpl>
which produces
Content page | Person | Task |
---|---|---|
Todotest1 | Brown, Sam | To be done by Brown, Sam |
Todotest2 | Sam Brown | To be done by Sam Brown |
Todotest3 | SBrown | have to do what it says by SBrown |
Note that the "i" makes the regexp case insensitive, so 'sbrown' would also match.
How do I produce a list or a table that begins with a template parameter instead of the article name?
Whenever I create a dpl list or table with template parameters it always produces a list with the article name appearing first. I would like one of the template parameters to appear first instead. For example, all the titles of books are the article names and each has a template with author, publisher, place of publication, and date. I would like to create a list in the format author, article title, place of publication, publisher, date (i.e., I want to automatically create bibliographic references in Chicago style with DPL). Is there a way to do this? Marcusperman 04:22, 7 March 2009 (UTC)
- Yes, there is a way: use a "-" as the second parameter of the table statement and use a phantom template which produces table rows. In this phantom template you can put a [[{{{%PAGE%}}}]] parameter in whatever column you like. Gero 17:52, 7 March 2009 (UTC)
Inserting spaces and comma in the output
Just use the numeric html alias for comma: ,; you may want to have a space after that 'comma', so line wrapping will work normally:
{{#dpl:category=MyItems|listseparators=,[[%PAGE%|%TITLE%]], ,,}}
I want the article list separated by comma
There is a mode called 'inline' which does what you want.
mode=inline inlinetext=,
This will give something like Nig1, Nig2, Nig3, Nig4
Why does my deleted page still appear on Special:Wantedpages?
When a page is categorized such that it appears in a DPL query and is subsequently deleted, it will immediately disappear from the DPL query results. However, depending on how long the page has been around, it will temporarily still appear on Special:Wantedpages and navigating to the page's What Links Here page will still show the DPL query page as a page that links to it.
To get it to stop that unruly behavior, do one of the following:
- Wait awhile (an hour or so). The wiki will sort this out over time in a background process.
- Execute 'php runJobs.php' in the maintenance folder of your MediaWiki installation
- Open the DPL query page in edit mode and save it again (this will add to your Recent Changes page)
- Add reset=all in a final DPL query on the query page (see here.) This has other side effects - read about it first.
Why does my deleted page still have a link to a query page in its What Links Here list?
The answer to this is already in the previous section, but we wanted you to be able to find your question anyway.
How do I 'see' the wikitext my DPL generates?
There is a simple trick to DEBUG your DPL script:
Use a resultsheader and a resultsfooter to enclose all DPL output in pre and nowiki tags like this:
<dpl> ... resultsheader=<pre><nowiki> resultsfooter=</nowiki></pre> ... </dpl>
NOTE: since version 1.4.2 you can also use the debug parameter. Just set "debug=5" in your DPL!
How do I offset an ordered list by a certain number?
Use the format statement and define an offset for the list:
<dpl> category=Fictitious country format=<ol start="4">,<li>%PAGE%</li>,\n,</ol> </dpl>
- DPL Example 007 main page 1
- Nigunda
- Nigunda Test
- Somango
Can DPL improve the MediaWiki search dialogue?
You can use DPL to show a list of files which match the search expression.
You could change your Mediawiki:Noexactmatch template as follows:
'''There is no page titled "$1".''' You can [[:$1|create this page]]. <dpl> debug=1 resultsheader= ''There are some pages similar to '$1':''\n titlematch=%$1% ignorecase=yes </dpl>
As an example enter 'rep' into the searchbox of this wiki and watch the response page.
How do I create tabular output?
The answer is (surprisingly) quite simple. There are a several of different methods depending on the data you want. Example A) and B) below return page 'meta-data'. Example C) below returns data on the page itself, either from within specific page sections or from templates used on the page.
A) A table of page meta-data;
The 'parser function' syntax of the DPL ({{#dpl:...) gives the cleanest looking code, and is used below for that reason. However, the regular <DPL> syntax works in an identical way but with different layout.
{{#dpl: |category = Country |count = 10 |mode = userformat |addauthor = true |addpagesize = true |addpagecounter = true |addfirstcategorydate = true |userdateformat = d-m-Y |listseparators = {¦ class="sortable" \n! \n! Date \n! Name \n! Author \n! Views \n! Size \n¦-, \n¦ align="right" ¦ %NR% \n¦ align="right" ¦ %DATE% \n¦ align="left" ¦ [[%PAGE%]] \n¦ align="left" ¦ [[User:%USER%¦%USER%]] \n¦ align="right" ¦ %COUNT% \n¦ align="right" ¦ %SIZE% B, \n¦-\n, ¦} }}
Gives;
Date | Name | Author | Views | Size | |
---|---|---|---|---|---|
1 | 02-09-2007 | Nig1 | Gero | %COUNT% | 166 B |
2 | 02-09-2007 | Nig2 | Gero | %COUNT% | 166 B |
3 | 02-09-2007 | Nig3 | 67.41.66.71 | %COUNT% | 174 B |
4 | 03-09-2007 | Nig4 | 67.41.66.71 | %COUNT% | 198 B |
5 | 05-09-2007 | Category:CountryA | 67.41.66.71 | %COUNT% | 301 B |
6 | 05-09-2007 | Category:CountryB | 67.41.66.71 | %COUNT% | 301 B |
The key to understanding how this works is;
- understand DPL basics (link?),
- understand table syntax, and
- understand the listseparators parameter.
Once you understand these things you will understand the above DPL.
B) The same table of page meta-data using the 'table' parameter;
I wish I knew how to do this...
- The 'table' parameter is designed to create tabular output for elements which come from an include statement. So you would have to use a surrogate template ('phantom template') which could use the %variables%. But this works only if there exists a template which each of your article uses exactly once. So, normally you will have to use the approach shown above .
- Gero 15:45, 18 September 2007 (CEST)
- Can you show us how would it would look? (Assuming we had a template that was used in each page exactly once). --Dmb 21:29, 20 September 2007 (CEST)
C) A table of page section or template data;
See Test table.
I try to generate table formatting with DPL but it looks weird - to hell with the syntax!
Indeed, complex queries can be somewhat tricky. But this is not only a problem of DPL. MediaWiki is quite sensitive to blanks and linefeeds and half of your problems will probably come from there.
There is a simple trick how you can DEBUG your DPL script:
Use a resultsheader and a resultsfooter to enclose all DPL output in pre/nowiki tags like this:
<dpl> resultsheader=<pre><nowiki> resultsfooter=</nowiki></pre> titlematch=Nig% include=%1[300] format={|class=wikitable\n!article\n!beginning\n|-,\n[[%PAGE%|%TITLE%\n,\n,\n|} </dpl>
You can also simply set debug=5 to achieve the same effect.
If we execute the above query (without the debug header/footer) the result will be deeply unsatisfactory:
article | beginning |
---|
But why?
With our little trick we can watch the output of DPL which would normally be immediately rendered by the wiki parser:
{{Extension DPL}}{|class=wikitable !article !beginning |- [[Nig1|Nig1]] [[Nig2|Nig2]] [[Nig3|Nig3]] [[Nig4|Nig4]] [[Nigunda Test|Nigunda Test]] Nigunda Test History - Chapter Sequence in the article doesn´t matter for DPL .. [[Nigunda|Nigunda]] some facts about religious groups in Nigunda; some other facts about religious groups in Nigunda; [[Category:Tag_Event2]] [[Nigeria|Nigeria]] :<div class="noprint">''Main article: [[History of Nigeria|History of Nigeria]]''</div> :<span class="boilerplate seealso">''See also: [[:Nigerian military juntas of 1966-1979 and 1983-1998|Nigerian military juntas of 1966-1979 and 1983-1998]]''</span> More than 2,000 years ago. the [[Nok]] [[Nigeria#History|..→]] |}
And now we see: After the |- the next table row does not start with a '|'; and, apart from that, there is no "end of row" after each article. Now it is easy to correct the DPL query:
<dpl> titlematch=Nig% include=%1[300] format={|class=wikitable\n!article\n!beginning\n|-,\n|\n[[%PAGE%|%TITLE%]],\n|-,\n|} secseparators=\n|\n, </dpl>
.. and we get the desired result:
article | beginning |
---|---|
Nigunda Test History - Chapter Sequence in the article doesn´t matter for DPL .. | |
some facts about religious groups in Nigunda; some other facts about religious groups in Nigunda; | |
In our "debugger" it looks like this:
{{Extension DPL}}{|class=wikitable !article !beginning |- | [[Nig1|Nig1]] | |- | [[Nig2|Nig2]] | |- | [[Nig3|Nig3]] | |- | [[Nig4|Nig4]] | |- | [[Nigunda Test|Nigunda Test]] | Nigunda Test History - Chapter Sequence in the article doesn´t matter for DPL .. |- | [[Nigunda|Nigunda]] | some facts about religious groups in Nigunda; some other facts about religious groups in Nigunda; [[Category:Tag_Event2]] |- | [[Nigeria|Nigeria]] | :<div class="noprint">''Main article: [[History of Nigeria|History of Nigeria]]''</div> :<span class="boilerplate seealso">''See also: [[:Nigerian military juntas of 1966-1979 and 1983-1998|Nigerian military juntas of 1966-1979 and 1983-1998]]''</span> More than 2,000 years ago. the [[Nok]] [[Nigeria#History|..→]] |- |}
Where can I talk about DPL?
Try here;
- irc://irc.freenode.net/#DPL
- On the mailing list?
- On a discussion page somewhere on this site...
- IRC is a lonely place :) so how can I get on the mailing list? Siri J 19:11, 22 November 2009 (UTC)
Using multiple categories with phantom template
I am absolutely indebted to the work on DPL. I pulled my hair out for 2 days trying to figure out a way to do this. One thing I can't figure out is using a phantom template with multiple categories separated by | will only return results from the category listed first. I have:
{{#dpl: |category=Maintenance 2007 Week 41|Maintenance 2007 Week 42 |include={Infobox Maintenance}:date:start:end:page |count=8 |table=class=maint,-,Date,Start,End,Title }}
It only will display the output (correctly - date, start, end, page) from whichever category I list first, although it does it correctly. Is there anything I can do to fix this?
Here is one of my call to Infobox Maintenance in Category:Maintenance 2007 Week 42
{{Infobox Maintenance |title=Scheduled Maintenance on hosting environment |date=10/17/2007 |start=4:00 AM |end=8:00 AM |description=blablah }}
- I think your problem lies in the pipe symbol. If you use the parser function syntax like you did in your first query the mediawiki parser will grab each '|' and will think it found the beginning of a new parameter. Try to escape the | by using {{!}} and you probably will get the correct result. Apart from that problem I wonder why you don´t get an error message. I think I will have a look at that. Gero 19:48, 15 October 2007 (CEST)
- I had a look at the code and found that parameters which do not contain a "=" sign are silently ignored. In the next release there will be a warning in such situations. This should be enough to draw your attention to the pipe symbol, I guess.
- A last remark: This document is the wrong place for problem reports. Please reply after you solved your problem and then I will remove the entry here. We use the Issue documents for problem reports. Gero 20:12, 15 October 2007 (CEST)
- That works perfectly! Thanks for the quick response for a project that I have been under pressure to complete. I wasn't sure where to place the question. I assumed there was--Xigxag 21:28, 16 October 2007 (CEST) a problem with my syntax usage, not an issue with the extension. Thanks for the help and your hard work. --Xigxag 03:49, 16 October 2007 (CEST)
- Another question - How would I go about suppressing the dpl no results warning message when using in the context above? I use |noresultsheader= but it doesn't seem to work.
- use debug=1 or put a html comment (or a non breaking space nbsp;) directly after the noresultsheader= clause. Gero 08:43, 16 October 2007 (CEST)
- Ah great. Things are looking quite nice now. I am going to look into using the calendar in the future. Thanks again. --Xigxag 21:28, 16 October 2007 (CEST)
- use debug=1 or put a html comment (or a non breaking space nbsp;) directly after the noresultsheader= clause. Gero 08:43, 16 October 2007 (CEST)
- Another question - How would I go about suppressing the dpl no results warning message when using in the context above? I use |noresultsheader= but it doesn't seem to work.
Can DPL be used to post text based on category of current page?
I would like to print different output depending on the category of the current page. For example, if the current page is in category "able", "baker" should print, otherwise "charlie". --C4duser 19:48, 22 November 2007 (CET)
DPL can easily be used for that. title is filled with the current FULLPAGENAME and [no]resultsheader is used to create the output. Care should be payed to the fact that we must accept the current page as part of the query result (se skipthispage).
<nowikli> {{#dpl:title={{FULLPAGENAME}}|skipthispage=no|category=able|resultsheader=baker|noresultsheader=charlie}} </nowiki>
How would I code a DPL tag be used to post a category list of when the article was created/updated for the current month
I would like to display all articles created and/or modified (updated) for the {{currentmonth}}. Can this be done? ... if {{currentmonth}} can't be used, how would I code a specific month (i.e., date=May%) to give me the result?
I need to use a comma in my regexp but DPL uses the comma as a separator ..
Use \x2c in yopur regexp. The hex code 2c (dec. 44) is equivalent to a comma within a regular expression.
Can DPL be used to create statistics per user?
I would like to use DPL to create information on a given user, as follows:
- Total number of edits for all articles.
- Earliest edit date for all articles.
- Total number of articles edited.
Is this possible? If so, could you give an example.
Thanks.
--C4duser 16:02, 31 December 2007 (CET)
Have a look at the scattergram which I put on the homepage of this wiki (see Scatter Demo 2). You might use a similar approach.
- Gero 09:42, 2 January 2008 (CET)
Can DPL be used to create a subcategory listing with articles listed under their category
If I've got a category Colors with sub categories, Greens and Red, How can I automatically get a listing as follows
Colors
Green Articles in category green Red Articles in category red
but using the category=*Colors in the DPL query.
This works if I use a pipe separated list of Categories category=Red|Green , but was hoping to avoid having to do this.
Any help, very much appreciated.
Mark
Reply
You can use nested queries. Create an outer query that returns all subcategories of 'Color' and use the format= parameter to output the result in a way that it can be used as an argument for the categories= parameter of the inner query.
- Gero 14:06, 7 February 2008 (CET)
Example query, please?
I don't understand how to do this. Could you make an example query, assuming the category is "colors"? I'm not very good at this. You're the ones who said it was doable, now prove it :)
- DPL Example 007 Gero 22:08, 9 March 2009 (UTC)
Thank you! Dafydd 07:54, 10 March 2009 (UTC)
My templates suddenly breaks
If the new parser is enabled (by default it is) then a lot of templates breaks, especially during calls to DPL. This will happen with release 1.12 (?) and later. The old parser can be used instead of the new one by a small addition to the file LocalSettings.php
$wgParserConf['class'] = 'Parser_OldPP';
There might be introduced ways to do this from the code DPL-code itselves. Jeblad 17:23, 13 April 2008 (CEST)
How do you reference include parameters in a format statement?
With an include
line like this:
include = {my template}foo:bar:blat
how do you reference the values of foo, bar, and blat in a format
statement? I see how to do it in a tablerow
statement (with %%
) but this doesn't work with format
.
It would be helpful if the answer were documented here or here.
--Maiden taiwan 03:16, 1 May 2008 (CEST)
Reply
Currently there is no way to do this. That´s why it isn´t documented ;-)
I know that this would be quite a valuable feature to have but I do not have time for implementation. It should not be too hard to add this feature; I guess that for a person with some php experience it could be done in one day (but not in one hour ...) If you are going to change the code: please make sure that you use the sources from the latest version (1.72) as a starting point. Good luck! Gero 16:25, 1 May 2008 (CEST)
Sorting by the value of a template parameter?
Can DPL order its results based on the value of a template parameter? For example, suppose we have Template:Book
:
This book is {{{title}}} written by {{{author}}}.
Can DPL produce a list of all articles that use this template, sorted by author?
--Maiden taiwan 20:36, 9 August 2008 (CEST)
Another sorting question: this time by value of phantom template
I want to have a DPL output that is ordered by the value of what is pulled in from a template with the include= syntax. In a set of articles included in one category I have placed a phantom template with meta data information in it. I want to pull that information out and then order the list by that information. For instance:
<dpl>
category=dissertations
include={Dissertation info}:date
format=,# [[%PAGE%]]: ,\n,
</dpl>
This produces a list with the date after each page name, but I want the list given in order by that date. Is this possible? If so, how?
Marcusperman 00:12, 28 January 2009 (UTC)
Using DEFAULTSORT or other sort key to order results
I have a problem with lists of people, as alphabetical sorting (titlewithoutnamespace) is by page name and not by sort key. Listing them by first name works for very short lists, but as soon as there's more than 5-10 names we really need to sort by last name (see "Eksempel 4" for an example). The most practical solution would be to use DEFAULSORT, sorting by that key if it exists, and alphabetically by pagename if there is no DEFAULTSORT key. Is there any way to achieve this now, or if not, would this be possible in the not so distant future? I'm not up to writing code for something like thay myself, but I imagine that this would be a problem for others too. Cnyborg 02:18, 12 August 2008 (CEST)
- There is a solution for your problem which already works with the current DPL version, see Sort articles on people by last name! Gero 16:45, 15 August 2008 (CEST)
Random pieces of one page
Is it possible to display random pieces of text from one page as a DPL result? For sure they must be marked somehow (may be as chapters or list elements). I know that this is possible for a random set of pages for one category using the include parameter. --Silversurfer 13:49, 22 August 2008 (CEST)
- Solved for me. I use the RandomArea Mediawiki extension. --Silversurfer 18:48, 5 September 2008 (UTC)
- Indeed, this task is not well suited for DPL. DPL comes into the game when you want to pick content from more than one page. Gero 15:59, 12 September 2008 (UTC)
- Please, how did you combine randomArea and DPL? --Neodimio 09:33, 12 February 2009 (UTC)
- I don´t think they were combined at all. Gero 23:18, 13 February 2009 (UTC)
url/dynamic
Is it possible to parse variables into a page that uses DPL:includetrim?. URL Example:http://semeb.com/dpldemo/index.php?title=Test_includetrim¬titlematch=Random Chapter Content
--Messiah 14:12, 28 November 2008 (UTC)
How do you reference include parameters in a format/tablerow statement into a template?
With an include
line like this:
include = {my template1}:%PAGE%:%TITLE%:foo1:foo2:foo3
how do you reference the values in a format
/tablerow
statement into a {my template2}
?
I see how to do it in a format
statement, I can divide one info about one page:
include = {my template1}:foo1 format=, {{my template2|faa1=%TITLE%|faa2=,}},
if I need more info about one page, then I can use tablerow
statement:
include = {my template1}:%PAGE%:foo1:foo2:foo3 table =,-,link to page, foo1, foo2, foo3 tablerow = %%,%%,%%,%%
but I would like to use more info about one page into {my template2}
:
include = {my template1}:foo1:foo2:foo3 format=, {{my template2|faa1=%TITLE%|faa2=%foo1%|faa2=%foo1%|faa3=%foo2%|faa4=%foo3%}},
Are there any ideas?
--Bilardi 10:47, 22 January 2009 (UTC)
Reply
I am afraid your request is too complicated for the table statement. See Test table for the maximum you can achieve with the table command.
I suggest to use both templates within the include statement instead.
include = {my template1}.myFormat,{my template2}.myFormat
You will have to provide two phantom templates called 'my template1.myFormat' and 'my template1.myFormat'. Within these templates you can provide table row formatting according to your own preferences. There are some examples for this in the manual. The row break can be handled in the format statement (third parameter), start and end of the table must be given in the first and in the fourth parameter of the format statement.
This kind of formatting always becomes a little tricky if you cannot guarantee that both templates are used exactly once (or at least once) in each article. Also the sequence in which these templates appear in your article should always be the same ... Good Luck!
Gero 16:04, 23 January 2009 (UTC)
All articles that transclude from the main namespace?
Can DPL produce a list of all articles that transclude from a given namespace? For example, I want a list of all articles that contain a line like this:
{{:...}}
i.e., that transclude content from the main namespace. It should not be recursive. Maiden taiwan 15:57, 3 February 2009 (UTC)
tablesortcol ignoring identical values?
I'm using tablesortcol to change the default sort from the first column. It appears that if any items in the column have the same value, the other page(s) are ignored when the table is generated. I read the manual entry for tablesortcol and there does not seem to be any reference to this behavior. Billm 15:48, 24 March 2009 (UTC)
- I've found a related bug here: Issue:Tablesortcol, same value in two or more rows, wrong data. Billm 15:52, 24 March 2009 (UTC)
includematch
Hi! I want to select pages which contains 'hello world' in Example chapter. As i understand 'includematch' can help me, but i don't understand how to make it... I tried to paste expression from examples and always got PHP errors (about delimiter or offset). I just want to select pages which contains 'hello world' to add them to the table. What do i need? --Maaboo 13:37, 24 April 2009 (UTC)
Selection by MIME types?
Is it possible to select file page titles by img_major_mime or img_minor_mime? E.g. a list of images (img_major_mime=image) or a list of PDF files (img_minor_mime=pdf). --Subfader 00:50, 29 April 2009 (UTC)
- Iknow you can you titlematch = %.pdf but that's not 100% :) --Subfader 17:38, 30 April 2009 (UTC)
Last edits which are not page creations?
How to list pages which were recently edited by a specified user but excluding those which were created by that user but not edited afterwards? I'm using this atm:
|modifiedby=UserName |ordermethod=lastedit |order=descending
So: Do not don't count page creation as edit. Any ideas? --Subfader 00:50, 29 April 2009 (UTC)
[RESOLVED] Include: Exclude category tags
When your wiki articles have the categories at the end right below the last section and you want to include exactly the last chapters the page in which include those will list all teh category tags (example). I searched hard but didn't found a way to get rid of the category tags. --Subfader 01:39, 30 April 2009 (UTC)
- Solved hiding the div#catlinks in MediaWiki:Common.js. There might be a solution using {{#replace:}} though, but no idea how to add that to include=.--Subfader 16:30, 1 May 2009 (UTC)
- Ugly solution by using #regex. --Subfader 14:56, 8 May 2009 (UTC)
- ----
- Indeed;: there is a simple solution using #replace. It requires, however, that you produce tabular output because it relies on the possibility of the tablerow statement to apply a regular expression to the content of a column:
{{#dpl: |titlematch=Somalia |include=#%-1 |table=,,last chapter |tablerow=²{#replace:%%¦/\[\[Category:.*\]\]\s*/¦¦}² }}
delivers:
- Gero 10:13, 9 May 2009 (UTC)
#replace is limited and i get "string exceeds 1000 characters" and I don't want to raise the limit. I use it this way atm:
{{#regex: {{#dpl: .... }} |%\[\[Category?(?(?=[^\[\]\{{!}}]*\{{!}})[^\[\]\{{!}}]*\{{!}}{{!}})([^\[\]]*)\]\]\n%|}}
I don't know regex much but categories including : still slip through it, e.g. Foo: bar > [[Category:Foo: bar]]. Can you help on this? Thanks ;) --Subfader 10:16, 11 June 2009 (UTC)
- Escuse my dumbness. Your version of course works in {{#regex as well :) --Subfader 01:12, 6 July 2009 (UTC)
Upcoming cache mechanism
I just found out that there is an upcoming cache mechanism. Will it make DPL faster? I really look forward to it if that's the case. I experience quite heavy loading times on pages with more than 3 different DPL statements. --Subfader 12:06, 1 June 2009 (UTC)
- Probably yes. I will use a separate cache for each DPL statement and the cache manager will recognize if the DPL statement on a page has changed (during editing). The whole thing is more complicated than I thought because there is a bunch of caches involved: the browser cache, an optional proxy cache on client side, an otional MW cache engine for HTML pages, the MW parser cache and (of course) the DPL cache. I will need people for testing once the first version of the DPL-cache is released. May I count on you? Gero 21:00, 2 June 2009 (UTC)
- Will of course test it. But I don't have much time before July. --Subfader 17:42, 3 June 2009 (UTC)
Displaying subcategories like the default in wiki
Hello, I am trying to display the subcategories of a category in the same manner as how the wiki does it automatically by default. (i.e. link ->see the subcategories section). Is it possible to get that kind of format in DPL? If no, any other way to do so would be appreciated! (I tried to find that code within the mediawiki but I don't know where it's buried...)Casshyr
- You mean the [+] in general (here) or to display the subcats of a cat on e.g. an article (here)? But I think if you made it to end up here you must mean the latter :D --Subfader 00:28, 18 June 2009 (UTC)
- Thanks for the reply! However it isn't what I was after (sorry I wasn't clear). Here's a better link that shows more of what I am after: link2. In that link, I like how the subcategories are organized into multiple columns and so far the examples I have explored on DPL only have single column, and if I try using 'mode=category', it only outputs the articles and not the subcategories themselves. I am more interested in showing the subcategories. Thanks! Casshyr
- You still didn't were clear. In your example only the articles are sorted into columns. The subcat section has only 1 coulmn. But you surely mean the groups wit the starting letter A, M, P. No idea how to output that in DPL. --Subfader 23:04, 18 June 2009 (UTC)
Pages with DPL code should not "use" the results or "link from" them
Ok I have checked all options but I simply can't get it working that a page using DPL code is not listed in "What links here" and "File links" on image pages. I tried eliminate and reset for images and links, but still Image:Bob Ross.gif lists the DPL pages resulting this image. Actually only Muha Test and Muha Test 2 really use them and only this FAQ page links to that image.
So what needs to be set in the DPL code to suppress those references? Furthermore, can we have a global to set in Localsettings if one never wants this since DPL lists are dynamic those references make no sense at all. --Subfader 18:03, 5 July 2009 (UTC)
- I added "reset=all' to the last query on your page and now the beackrefs are gone. I think 'eliminate' should do the same job - although it is al little more 'expensive' internally. Maybe the problem is that you did not add it to the LAST query in your article? --Gero 06:52, 6 July 2009 (UTC)
- I see, it's complaicted :D I tested around and now I can't reset it again your way. See Image:Placeholder.png is embedded on no page but without those resets it will not be "unused". I can't think of a list where I want this to be the case, esp since DPL is dynamic. Can't there be a global? --Subfader 07:30, 6 July 2009 (UTC)
linkstoexternal
What's up with linkstoexternal? There is no manual for it anymore? It works fine though: User:Subfader/External links. On my own wiki I use v1.7.7 (cos of %TOTALPAGES% bug) and it doesn't work. --Subfader 15:51, 23 July 2009 (UTC)
How do I select pages with numeric parameters?
My wiki uses templates with parameters like |min_age= 4 and |max_age= 12. I want to make lists of pages for a certain age: min_age < age < max_age. So pages with a min_age equal or lower than the age and a max_age equal or higher than the age. Can that be done and what is the best way to do that? --Egel 17:53, 23 July 2009 (UTC)
- http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23ifexpr: --Subfader 20:53, 23 July 2009 (UTC)
- I have found a way to do it.
- the table:
<dpl> allowcachedresults=true uses = sjabloon:Spel include= {spel}:minimum leeftijd:maximum leeftijd:%PAGE% table= class="sortable wikitable",-,Spel,Minimum leeftijd,Maximum leeftijd tablerow= ²{Spel.lijst|5|7|%%,%%,%% }² </dpl>
- the template:Spel.lijst
style= "{{#ifexpr: ({{#if: {{{3|}}}|{{{3}}}|5}} > {{{1|0}}}) or ({{{2|0}}} > {{#if:{{{4|}}}|{{{4}}}|99}})|display:none|}}"|[[{{{5}}}]] |style="{{#ifexpr: ({{#if: {{{3|}}}|{{{3}}}|5}} > {{{1|0}}}) or ({{{2|0}}} > {{#if:{{{4|}}}|{{{4}}}|99}})|display:none|}}"|{{{3|}}} |style="{{#ifexpr: ({{#if: {{{3|}}}|{{{3}}}|5}} > {{{1|0}}}) or ({{{2|0}}} > {{#if:{{{4|}}}|{{{4}}}|99}})|display:none|}}"|{{{4|}}}
- Empty parameters are not really empty so I needed to do {{#if: {{{3|}}}|{{{3}}}|5}} in stead of {{{3|5}}}. I didn't find a way to change the style of a row in one go so had to do it cel by cel. Can I do this in a more simple way? --Egel 12:37, 24 July 2009 (UTC)
- Params not really empty: what do they contain? Try #iferror. Works if a param reads text while being compared to a number. --Subfader 14:54, 24 July 2009 (UTC)
- I think that DPL adds whitespace characters (space, newline, etc) to (empty) params, after that the params are not empty enough to trigger the default value. If have tried #iferror, you will get a longer and more complicated code.--Egel 18:09, 25 July 2009 (UTC)
- Params not really empty: what do they contain? Try #iferror. Works if a param reads text while being compared to a number. --Subfader 14:54, 24 July 2009 (UTC)
- Did you have a look at the includematch command? I think it is perfectly suited for your problem. It allows you to filter output by a regular expression - a numerical range of values would have to be translated to an OR-expression like (9|10|11) or to a range expression like [567]. The advantage is that you will only get the results you want, so you do not have to make unwanted resuklt lines invisible. Gero 19:19, 24 July 2009 (UTC)
- I hoped I could use the first piece of code as a template or with the Call extension, so something like {{{start}}|{{{end}}} instead of fixed numbers. Has anybody an idea how I could do that? --Egel 18:09, 25 July 2009 (UTC)
- I hope that I can help to find an elegant solution. Please add a few demo pages to this wiki and then show us the query you came up with and the result it produces. Maybe it is possible to produce the same result with less code (this is always a goal worth thinking about). If you can demonstrate where DPL adds whitespaces I may be able to eliminate that (or to explain why I think it is necessary..) Gero 22:18, 25 July 2009 (UTC)
- I hoped I could use the first piece of code as a template or with the Call extension, so something like {{{start}}|{{{end}}} instead of fixed numbers. Has anybody an idea how I could do that? --Egel 18:09, 25 July 2009 (UTC)
- Empty parameters are not really empty so I needed to do {{#if: {{{3|}}}|{{{3}}}|5}} in stead of {{{3|5}}}. I didn't find a way to change the style of a row in one go so had to do it cel by cel. Can I do this in a more simple way? --Egel 12:37, 24 July 2009 (UTC)
Define DPL Cache time period?
Is it possible to define a time period after which the cache should be refreshed? E.g. user clicks, dpl checks how old the chache file is, if the difference to now larger than [definition] run the query and update the cache file. Cos atm I can't think of a DPL code for my wiki where I'd use cache since the results may be a few days old. but with defining 30 mins only it could be fresh data and save ressources. But I guess you don't have much influence on the MW cache? --Subfader 00:52, 30 July 2009 (UTC)
---
yes, the command dplcacheperiod (see the manual) allows you to set the number of seconds. For one day (default) you would write 84400, for five days it would be around 400000 etc.
If you want to have less than the default period of the MW parser cache (usually 1 day) there is a trick: define the page with your query as 'volatile' (which is the default normally; it can be explicitly set by allowcachedresults=false) and then set dplcacheperiod to a value of 2000 (e.g.).
MW will treat the page as dynamic, but DPL will use its cache so that no database access will happen within the cache period.
The only problem with this approach is that MW must render the result page each time the page is called. DPL does NOT do a recalculation within the dplcacheperiod, so the time spent within DPL should be below 10 msecs. But the MW engine has to translate the wiki text which DPL has fetched from its cache to HTML every time. Normally this is quite fast, but if the DPL result is huge and especially if it contains a lot of wiki links' all the links must be checked - which can take some time (depending on machine size)
Gero 12:23, 30 July 2009 (UTC)
- Alright, thanks for the detailed info. The trick would work as desired. I don't use any cache atm anyway so if the wiki page itself stays uncached and the only difference is that the dpl result is cached (most of the time), then everything it's perfect. Thinking about it I may see the next problem: Is it possible to cache DPL result but not wiki pages? Excuse my cache noob questions. --Subfader 13:25, 30 July 2009 (UTC)
- This is exactly what happens if your page is 'dynamic'! Wiki code (and other extensions) will be parsed every time. Only DPL bypasses its normal work by accessing its own cache. You can test this if you EDIT a page which contains a DPL statement using the dplcache. As long as you do NOT touch the DPL statement you can make other changes in the wiki source. After saving the article you should still get the old cached result as long as the dplcacheperiod has not expired.
- BTW: There is a subtle problem with "UNIQ-QINU-sequences" appearing sometimes in the output of DPL when you use the dplcache. I am tracking down this problem currently. Gero 06:03, 31 July 2009 (UTC)
- Hmh, as soon as I set $wgUseFileCache = true; all wiki pages are cached to anons. But I only want DPL results to be cached (for all or just anons, no matter). --Subfader 18:18, 31 July 2009 (UTC)
Article with response to DPLs query produces high load
- Caching ist a nice feature it prevents heavy sever load.
- I still see a problem. Heavy load if i'm editing an article and this article is referenced by a DPL query. What to do...
- If a query in page A lists a page B as part of its result you will normally get a backlink from B to A in the database. The creation of the backlink may depend on the exact kind of output mode you are using. If you just list the articles in the standard way it will not be created, but if you generate wiki syntax in your DPL format statement you will get the backlinks. I am not sure if the backlinks slow down editing B ( I think they slow down editing A). But anyway you can prevent the backlinks from being created in the database by using reset or eliminate within the DPL query in page A. Please let me know if this solved your problem! --Gero 10:50, 31 August 2009 (UTC). I still use reset=links Problem is fixed. --Armin.Egner 14:59, 4 September 2009 (UTC)
Specifying colors to DPL table cells
- This question is similar to question #1. Is it possible to specify the cell color without using conditions (ex. if statement)? I am in a situation where I KNOW what the color should be for a cell, but since the content of the cell does not determine the color, I can't use the condition code from DPL Example 003. I know wikitable is possible to do so, but for my purpose, I also need to incorporate some functions that only DPL table has. Any help is appreciated!! Note: I also tried the tablerow statement but that didn't work because then only made all my cells for the specified column the same color
- I assume that you want different colors for the same column depending on row content or some external factors which cannot be specified within the tablerow statement.
- In this case you should use phantom templates for formatting. Within the surrogate (phantom) template you can do whatever you want and you have the content of ALL columbs of a row available to decide in the colouring. See DPL_Example_004 and add the code for cell formatting within the phantom template. Gero 06:24, 3 September 2009 (UTC)
Include and parser extension calls with parameters
Can I use include/includepage with parser extension calls that has parameters? Example: <func param1="1" param2="2"> I'm attempting to use DPL and include googlemap extensions calls, but haven't been able to get this to work. --Henning 08:43, 27 September 2009 (UTC)
- No, currently we do not analyse parameters within XML tags; maybe some time in future... Gero
- Actually, I'm not interested in the parameters, I just need the body. --Henning 22:23, 27 September 2009 (UTC)
- Use %TAGBODY% as shown in DPL_Example_028. Gero 13:43, 28 September 2009 (UTC)
- Sorry, what I meant was that I don't need the parameters in the phantom template, but the parameters are needed in the pages. Include/includepage works fine when googlemaps is used on a page like this: <googlemap>...</googlemap>, but not like this: <googlemap version="0.9" lat="10.00000" lon="10.0000" zoom="10">...</googlemap> I guess this functionality isn't supported yet. --Henning 08:51, 4 October 2009 (UTC)
- Use %TAGBODY% as shown in DPL_Example_028. Gero 13:43, 28 September 2009 (UTC)
- Actually, I'm not interested in the parameters, I just need the body. --Henning 22:23, 27 September 2009 (UTC)
Using Extension:UserFunctions as a parameter
I have the problem that I can't get any results with my DPL,if I use the extension 'UserFunctions' especially the function to get the current username.
I want to build a DPL, that shows on ONE page all doucments of the current user loged in.
If I use this function for the parameter 'createdby' I don't get any results. It's a little bit strange, because if I use this function with the parameter 'noresultsheader' exp.: noresultsheader=No docs for {{#username:alt}} I get the no results message: No docs for USERNAME!
Code example:
<DPL> createdby = {{#username:alt}} order = descending notnamespace = Vorlage notnamespace = Bild mode = userformat listseparators = ,\n* [[%PAGE%]], noresultsheader=Keine Dokumente für {{#username:alt}} </DPL>
Any ideas?? --Donray 13:05, 30 September 2009 (UTC)
Reply
You must use DPL as a parser function; otherwise the expansion sequence of the MW parser will prevent DPL from seeing the result of the #username function. The following code works:
{{#dpl: | createdby = {{#username:alt}} | order = descending | notnamespace = Template | notnamespace = Image | mode = userformat | listseparators = ,\n* [[%PAGE%]], | noresultsheader = Keine Dokumente für {{#username:alt}} | resultsheader = Dokumente, die von [[User:{{#username:alt}}¦{{#username:alt}}]] angelegt wurden:\n | count = 10 }}
Gero 07:05, 1 October 2009 (UTC)
Reply
Thanks for the quick solution =) it works! Weird is, that if I use this dpl:
<DPL> notcreatedby= {{#username:alt}} addpagecounter = true notnamespace = Vorlage count = 20 mode = userformat listseparators = ,\n* [[%PAGE%]] , (%COUNT%),, noresultsheader= Keine News für {{#username:alt}} </DPL>
It works without problems, only that I use another parameter with the variable Oo but I use your example now!
Donray 09:04, 1 October 2009 (UTC)
Error setting up DPL
Hi, I am having trouble setting up DPL extension on my mediaWiki. I tried both the newest version as well as a previous version. The error messages I get are:
Warning: Parameter 1 to Language::getMagic() expected to be a reference, value given in C:\xampp\htdocs\mw\includes\StubObject.php on line 58
Warning: Parameter 3 to ExtDynamicPageList::dplTag() expected to be a reference, value given in C:\xampp\htdocs\mw\includes\parser\Parser.php on line 3323
I get these messages when I add the require_once lines for String Functions and Dynamic Page List respectively. Also, when I try to generate simple DPL tables, they don't work, but the same DPL code that I tried on another working mediaWiki, it works. Any ideas? Thanks!
- No, I have never come across such a problem. I recommend to set up your wiki by adding extensions one after the other. Maybe you could start with DPL and check if it works. Then add others and note the moment where problems begin to appear. Gero 11:46, 18 October 2009 (UTC)
uses foo AND bar?
How can you select pages that use Template:Foo AND Template:Bar (not logical OR)?? --Subfader 23:20, 30 October 2009 (UTC)
- Currently this is not possible. Gero 17:33, 1 November 2009 (UTC)
- I beg to differ! It is entirely possible, simply not with the usual DPL. You could use DPL to generate a list of pages using Template:Foo, and for each result, make a new DPL query which searches for pages using Template:Bar. Use something like format={{lb}}#ifeq:{{lb}}#dplvar:1stTitle{{rb}}|%TITLE%|%TITLE%{{rb}} where you use dplvar to repeatedly assign 1stTitle the value of %TITLE%, at the beginng of each result of the top-level DPL. (Note that I'm using the templates lb and rb to contain the text "Template:" and "" to escape braces. Also, I'll use the template equals to escape "=".) So I guess your code might look something like this:
{{#dpl: uses=Template:Foo| format={{lb}}#dplvar:set{{!}}1stTitle{{!}}%TITLE%{{rb}}{{lb}}#dpl:uses{{equals}}Template:Bar{{!}}format{{equals}}{{lb}}lb{{rb}}#ifeq:{{lb}}lb{{rb}}#dplvar:1stTitle{{lb}}rb{{rb}}{{lb}}!{{rb}}%TITLE%|%TITLE%{{lb}}rb{{rb}}{{rb}}}}
- Note: I'm not sure when the %TITLE% part gets parsed, so you might need to put the part about #dplvar:set|1stTitle within the second dpl call. I think you also might be able to write the code with less escapes if you use - the parser extension format, <DPL>, but I don't know - I really can never quite tell what gets parsed when. Something like this should work, though. Hopefully. timeroot 07:57, 3 January 2010 (UTC)
find pages that contain certain text
Hi, I wanted to get a list of all pages that contain certain text under certain chapter, so I've made a DPL like this:
{{#dpl: namespace = | shownamespace = false | category = Uputstva {{!}} Procedure | category = Status:_ODOBREN | notcategory = Status:_U_IZRADI {{!}} Status:_KONAČAN | includepage = #Lista distribucije | includematch = /Milan.stajcic/ | noresultsheader = '''Ovaj korisnik nema potpisanih dokumenata.''' | resultsheader = '''Ukupno %PAGES% potpisanih dokumenata.''' }}
And it works fine, but I would also like it to display only the page titles, which is a 'default' DPL behaviour, and NOT the included (and searched) text. Is this possible? --Vladap 13:46, 5 November 2009 (UTC)
- It should help if you add [0] behind the includepage command:
| includepage = #Lista distribucije[0]
This will tell DPL to cut the visible portion of the included text down to zero, but the match should still be made against the whole text. Gero 14:52, 5 November 2009 (UTC)
How can I have a separator like inlinetext when I'm using mode=userformat?
When I use inlinetext, the separator is only printed between articles (five articles = four separators). So markup like:
{{#dpl: |mode=inline |inlinetext= • |category=Admin users }}
produces a list like:
- User:Bob • User:Dave • User:Janet • User:Lucy
However I want to use a custom format to get rid of the namespace from the links. So I use markup like:
{{#dpl: |mode=inline |category=Admin users |format=,[[%PAGE%|%TITLE%]], • , }}
which (for obvious reasons) produces a list with an extra separator on the end (like a fence-post error):
How can I get behaviour that is more similar to inlinetext (so I don't get the additional separator on the end of the list) but still have control over the formatting?
- Japher 15:50, 17 December 2009 (UTC)
Response
The easiest way to achieve this is to explicitly remove the trailing separator by a #dplreplace statement. The following statement shows how to do it:
{{#dplreplace:{{#dpl: |mode=inline |namespace=User |titlematch=A% |count=4 |format=,[[%PAGE%|%TITLE%]], • , }}|/ • $/|}}
AJim • Aaron Overton • Adomjan • Alf63
--Gero 08:48, 20 December 2009 (UTC)
- Excellent, thanks Gero! --Japher 17:03, 6 January 2010 (UTC)
- Gero, I don't have dplreplace, and I notice that is only recently include in DPL v1.9.0. Is there any way that I can get this version? The most recent version I can find seems to be v1.8.9. Is v1.9.0 released yet? --Japher 14:25, 12 January 2010 (UTC)
- An easier way is to just set inlinetext after the format parameter.
- Test noeditsection ---Frankfurt ---Antwerpen ---Hamburg ---Munich
Best way to return list of new pages
On my heavily viewed Main Page I have a list of the latest uploaded images. Am I correct that the query (with any namespace) could be faster if only the recentchanges table was checked and not the image (or even article) table? Would this be possible? My query atm:
{{#dpl: |namespace=File |notcategory=Foo Images |notcategory=Bar |nottitlematch=%.mp3 |ordermethod=firstedit |order=descending |count=15 |format=,...[[File:%TITLE%]]...,, |eliminate=all }}
Is there a way to improve this? I'm using it for another "latest" list in this way and 2 lists by other extensions, so my Main Page takes wuite a while to load. Cheers --Subfader 20:37, 13 January 2010 (UTC)
Response
Maybe there is room for optimisation. The problem is that an optimised query might only work if you just want to have the name of the changed article. As soon as other conditions come into the game the join could be necessary. And, of course, each addition of code makes DPL fatter and harder to maintain ;-)
Anyway, I suggest the following:
You use debug=3 to get the SQL statement. You paste that statement into phpmyadmin and check its run time. Then you try to optimise the SQL statement. If you come up with a version that runs considerably faster, you leave a message here with both SQL statements (maybe you could mark the difference if it is not obvious). Then I can check the effort to teach DPL to use that "shortcut" under certain circumstances (i.e. if the DPL query does not contain other conditions which make it necessary to touch the articles table). O.k. ? --Gero 00:21, 14 January 2010 (UTC)
- Oh noes! Lost my reply I actually thought I posted back then. I didn't mean that it should be included and I understand that DPL shouldn't grow much more.
- I made some tests and I couldn't speed it up. on localhost (~1000 pages) the speed was fast enough, but on the server (26k articles) it varied between 0.3 and 0.5 seconds, which quite slow.
- I just thought the Recent Changes table would enable faster and nice queries like "Recently created arcticles", or even pages created today or in the past 24 hours. --Subfader 15:01, 17 January 2010 (UTC)
Return real %TOTALPAGES% while using DPL_fromTitle
%TOTALPAGES% reads the number of pages left when DPL_fromTitle is used. But it should return what it is ment to return: the total number of results for a DPL query.
Background: If you want to use a template of fixed "jump to" marks you can't return the number of total pages found with the query. I guess the reason is that scrolling is a new query each time?
I'd like to use DPL to replace the page section on category pages. As example see User:Subfader/JumpTo (using &DPL_fromTitle=...) vs Category:Events (using MW's &from=...). On The category navigation, note how the total stays the same and navigating back is possible.
So how could %TOTALPAGES% be properly used in let's say DPL Example 027?
If this shouldn't be possible, how to navigate through results as in Category:Events other than with DPL_fromTitle? --Subfader 00:36, 16 January 2010 (UTC)
Repsonse
The simplest way would be a second query which does not produce any output except the number of total pages. This sounds bad in terms of performance but maybe DPL could be taught to skip any processing of page titles if something like "format=," were given. Currently it will go through all pages and do nothing with them (which means a SQL FETCH without any need). Ideally you would want to see a SQL statement which only cointains a SELECT COUNT .. FROM ..."). I suspect, however, that performance overhead is not too big in many cases, so I recommend to try the simple approach of a dedicated "counter query" first.
Example: {{#dpl:category=Events|format=,|resultsheader=There are %TOTALPAGES% events in total.}}.
Example: There are 181 events in total..
--Gero 22:15, 17 January 2010 (UTC)
- That would be an option yeah. But it doesn't seem work and doesn't solve the odd navigation problem when DPL_fromTitle is used. Looks like I better don't replace category page lists with DPL. Thanks though! --Subfader 23:23, 17 January 2010 (UTC)
Summary Tables
Hello, I'm new to using wikis. I want to product tables such as the Math Project Summary Tables. I understand how I can use templates and variables to output a list of all the topics showing their priority and their quality. This would be a very big table and not very useful. I don't understand how to go from that simple table to a summary where one variable is compared to another. Could you give an examples? Thanks! Mrnlvr13 17:16, 22 February 2010 (UTC)
Multiple includes in one table cell
Hi,
I am trying to get multiple items from an Include call to display in one table cell.
Here is my dpl
{{#dpl: |uses=Template:Server |notuses=Template:Retired |nottitlematch=Server |include={Server}:InService:Type:OS:Func1:Func2:Func3 |mode=userformat |table=class="sortable",Name,In Service,Type,OS,Func1,Func2,Func3 }}
What I want is Func1, Func2 and Func3 to be displayed as an unordered list in one table cell. Is this possible? The above example gives a column for each Func. I played with tablerow, but couldn't work it out, and really wanted to use format, but found the documentation a bit tricky/incomplete for me.
Thanks! JonathanKing 00:08, 1 March 2010 (UTC)
- You should use a phantom template. The format statement defines the outer frame of the result table and the cell(s) are filled within the phantom template. Within the wiki source of the phantom template you can write wiki code to put arbitrary fields into one or more table cells. There are lots of examples here in this wiki how to use phantom templates. See the docs on include. Gero 21:44, 2 March 2010 (UTC)
Return user and date of page creation
There are %USER% and %DATE% as format options. The example mentions lastedit. Does that mean to return a list of new pages reading "Page - created by User on Date", you would have to add ordermethod=firstedit and the %USER% and %DATE% are automatically returning those dates instead of lastedit? --Subfader 12:11, 12 May 2010 (UTC)
- Indeed, that is what should happen by some magic ;-) Gero 18:30, 14 May 2010 (UTC)
- Yeah, noted that afterwards. It's awesome. Not too obvious from the format options tho. --Subfader 19:26, 14 May 2010 (UTC)
Show thumbnails for all images on a page
{{#dpl: |imagecontainer={{FULLPAGENAME}} |format=,:[[Image:%TITLE%|thumb|150px|Image: %PAGE%|%TITLE%]]\n,, }}
It seems to work sometimes and not at others when it returns no data in the main namespace. Any thoughts?
include and ParserBeforeStrip hook
In my LocalSettings.php I have a function to replace article text before it is parsed. This function uses ParserBeforeStrip hook.
But the text is not parsed when I include article sections using include.
How can I solve this? ParserBeforeStrip seems to be the only working hook for me tho. Either the content displayed via include is not sent to ParserBeforeStrip, or can I send the content to my function changing DPL? Assitenace on this would be appreciated --Subfader 13:15, 20 June 2010 (UTC)
- Nevermind, solved by adding a new hook. --Subfader 16:17, 23 June 2010 (UTC)
Playing with Template Parameters
Im creating a glossary and achieved to call the parameters into a table
|namespace=Glossar |include= {Glossareintrag}:kanji:romaji:text:link ... | tablerow =class="jap"¦%%,%%,%%,[[%%]]
What I would like to do is to play a bit with the results and get something like...
[[link|text]]
...as a result. Also I would like to ask, whether %% is empty or not and handle the result accordingly. Is there any way to do that? --Bescheid 21:33, 30 July 2010 (UTC)
- Read the manual and understand the concept of phantom (surrogate) templates. All you want to do can be´done with that technique ... 16:37, 31 July 2010 (UTC)
- OK, I'll give it another try... Thx, Bescheid 20:40, 2 August 2010 (UTC)
Selective Data from Table
I have a table on a page. It's easy enough to duplicate that table on another page..
|<DPL> | titlematch = foo/bar/page/page | namespace = | mode = userformat | includepage = #My Table |</DPL>
Is it possible to selectively grab columns from that table? For example, if this table has 6 columns, labeled col1, col2... can I grab just col1 and col6? It would look something like this...
|<DPL> | titlematch = foo/bar/page/page | namespace = | mode = userformat | includepage = #My Table | include = #col1,#col6 |</DPL>
This doesn't work, of course, but hopefully you understand what I'm looking for. Thanks in advance!
- You could apply a regular expression to the content of the paragraph by using ²{#replace: .....}² in the format statement. This should work. You have to use the #replace parser function that comes with the "StringFunctions" in the DPL distribution.
- The regexp will be applied to the included wiki text portion. As this is a table you will have many pipe symbols in it. Special escaping is needed in that case (see regexp syntax for php).
- I very much recommend another approach: Create the original table by calling a TEMPLATE for each row. Then it is very easy and straight forward with DPL to extract whatever column(s) you want in a second wiki page.
- Gero 11:04, 5 January 2011 (UTC)
Limits to DPL queries?
I am trying to use DPL to find all pages linking to some page. Using the Translate extension means our links must use a special format that is not recognized by the ordinary WhatLinksHere page or similar. I came up with this solution (here trying to find all pages containing the link [[Special:MyLanguage/Getting Help]] or the old style link [[Getting Help]]):
|<DPL> | namespace=Main |User | nottitleregexp = .*(/..(-..)?|_[(].*[)])$ | include = * | includematch = #\[\[[Ss]pecial\:[mM]y[lL]anguage/Getting[_ ]Help|\[\[Getting[_ ]Help# | includemaxlength = 0 | resultsheader = The pages in the translation system linking to Getting Help are:\n | format = ,\n* [[%PAGE%|%TITLE%]],, |</DPL>
This seems do do what I intended, but doesn't find all pages containing the text. I have experimented a bit, and find that when I narrow the search (fx searching only the Main namespace) I typically find more pages than with a broarder search. This leads me to suspect that I am having some sort of capacity problem. Since the results are very reproducible I wonder whether the query proceeds until some fixed capacity is exceeded. According to the sysadmins, however, there are no traces of any error messages in the logs. Is there a solution to this problem, or can I achieve my desired result with a more clever query? Claus chr 12:23, 7 August 2012 (CEST)
- That is due to the parameter "includematch" and the limit to dpl queries.
- "includematch" does not exactly work as a "page selection" parameter (like for example "category" or "titlematch"); includematch only "hides" all those found statements, that do not include the specified statement. Example: You search for all pages that link to WAZZUP and that contain the word "Hey"; say there are 800 pages that link to WAZZUP, then your dpl query will only get the first 500 (see limit in next paragraph) and then checks these 500 results against the "includematch = hey" statement; all of those 500 pages without a "hey" will then be omitted (hidden) from the final result. The problem is, that the other 300 pages (after the first 500 ones) were not found in the initial query and therefore will not show up, even if they contain "hey".
- Any DPL query is limited to a max of 500 results (unless you changed that in the settings); usually the parameter "count = xxx" allows you to increase that, but sometimes it doesn't work and you have to split your dpl call into several ones.
- My suggestion is that you split your dpl call in some way (maybe "titlematch = A%", "titlematch = B%", ...), so that each of these calls only contains at most 500 results (irregardless of the "includematch" statement). Then arrange all those different dpl queries in one neat table (you should use the parser function method {{#dpl: }} for these split up statements though).
- --Theaitetos 17:35, 9 August 2012 (CEST)
- Thank a lot for your answer. Unfortunately your suggestion is not going to work very well for us. If we can't filter on namespaces we are going to end up with an insane number of pages. In the main namespace we have about 1000 pages in English and about 2500 translated pages; but in the translation namespace there are on the order of 100000 pages (the way the translate extension works, each translated section gets its own page in that namespace). We'll try to increase the limit and hope our server can handle that. At any rate your explanation of what goes on is very useful.
- Claus chr 18:02, 11 August 2012 (CEST)
- Not sure what you mean, but filtering for namespaces does not pose a problem. Just write your dpl query the way you want and then split it up; example with our call from above:
|<DPL> | namespace=Main |User | nottitleregexp = .*(/..(-..)?|_[(].*[)])$ | include = * | includematch = #\[\[[Ss]pecial\:[mM]y[lL]anguage/Getting[_ ]Help|\[\[Getting[_ ]Help# | includemaxlength = 0 | resultsheader = The pages in the translation system linking to Getting Help are:\n | format = ,\n* [[%PAGE%|%TITLE%]],, |</DPL>
- Split into:
|<DPL> | namespace=Main |User | nottitleregexp = .*(/..(-..)?|_[(].*[)])$ | include = * | includematch = #\[\[[Ss]pecial\:[mM]y[lL]anguage/Getting[_ ]Help|\[\[Getting[_ ]Help# | includemaxlength = 0 | resultsheader = The pages in the translation system linking to Getting Help are:\n | format = ,\n* [[%PAGE%|%TITLE%]],, | titlematch = A%|B%|C%|D%|E%|F%|G%|H%|I%|J%|K%|L%|M%|N% |</DPL> |<DPL> | namespace=Main |User | nottitleregexp = .*(/..(-..)?|_[(].*[)])$ | include = * | includematch = #\[\[[Ss]pecial\:[mM]y[lL]anguage/Getting[_ ]Help|\[\[Getting[_ ]Help# | includemaxlength = 0 | resultsheader = The pages in the translation system linking to Getting Help are:\n | format = ,\n* [[%PAGE%|%TITLE%]],, | titlematch = O%|P%|Q%|R%|S%|T%|U%|V%|W%|X%|Y%|Z% |</DPL>
- --Theaitetos 21:03, 11 August 2012 (CEST)
- Thanks for this clarification. I had understood your original reply to imply that filtering on namespaces would be off when titlematch is use - rereading the reply I have no idea what made me think so. Combining filtering on namespaces and titles would indeed be possible. With a total of 3500 pages (and counting) in main namespace alone I still hope we can solve the problem by raising the limit on searched pages, though :-).
- Claus chr 16:50, 17 August 2012 (CEST)
- --Theaitetos 21:03, 11 August 2012 (CEST)