DPL:Discussion
Note: There is a special document for DPL:Bug Reports.
Existing bug reports in this document have been moved to the DPL:Bug Reports.
Exporting Table in CSV format
Does anyone know of a way to export a table created using dpl in csv format.
The table is simple: {{#dpl: |category=Senneville (Québec) |include=#Latitude, #Longitude, #POI Historical Details |table=,-,Latitude,Longitude,POI Historical Details }}
I just need some method to extract is out of Mediawiki in CSV.
Reply
There is a simply way if you do it manually: Just copy/paste the DPL output of the wiki page into an empty excel spreadsheet and save it in csv format.
If you want to do it automatically, you could use a DPL phantom template to create csv syntax. The csv text produced would then appear on the wiki page containing the DPL statement (typically one would use preformatted text for that purpose). It would be up to the user to pick that text, save it as csv and process it according to his preferences.
If you want to offer a file download with the csv file you will have to look for an extension which allows to write a file on your server's disk space.
Gero 09:01, 14 November 2009 (UTC)
Could make it possible to show page names by setting in a .dpl template page
I can show pagetitle by adding"%TITLE%" in listseparators but I still want to show the pagenames by adding {{PAGENAME}} or "%TITLE%" in the .dpl template page. Therefore, we can use descriptions such like {{sub:{{PAGENAME}}8|4}} or {{sub:%TITLE%|8|4}} to do something I want. Any ideas Thanks!--Roc michael 17:42, 5 July 2007 (CEST)
PAGETITLE in templates
You can use {{{%TITLE%}}} and {{{%PAGE%}}} within templates. See the manual. Gero 23:51, 5 July 2007 (CEST)
- Thinks, Gero! It works very well.--Roc michael 07:47, 7 July 2007 (CEST)
Concept of Subpages
Is there anybody who could explain what subpages are and if they are relevant for DPL ? --Gero 16:01, 15 February 2007 (CET)
Feedback
Thank you for this extension! I was able to create some rather complex queries that receive parameters through templates and that show a list of pages, creation date and author inside some categories. It solved our needs very well. Fernando Correia
Developer level access
Hi there. I was one of the original authors of the DPL (a long time ago, when MediaWiki was simpler and the extension fit on one printed page). I need to make a few changes to make the extension deployable on Wikinews — specifically, the addfirstcategorydate restriction to only work if only one category is included should be removed, and we need to add some simple date formatting to make it possible to show only the date, and not always the date and time (I was thinking of switching the default to show just the date as the older extension does, and make the date/time only appear if something like showdateandtime=true is specified.) I can make the changes, or provide patches; please let me know where the source code repository is (I notice that the mediawiki svn has a much older extension version). You can contact me by email, or at Wikinews -- IlyaHaykinson 11:26, 25 February 2007 (CET)
- I would like to support you in rolling out DPL to Wikinews. For the moment I added a generic feature for date formatting. This allows you to configure your date/time format individually, see the DPL:Manual#userdateformat. Sourcecode is here in this wiki but I plan to make it available also in subversion. Could you specify an example for your request regarding "addfirstcategorydate"? See also Test date formatting. -- Gero 15:36, 26 February 2007 (CET)
....
Help with a complex request?
I have the following situation...
- A) Many 'Template:' pages containing protected text derived from a third party (copyright requires 'verbatim' inclusion of the text).
- B) Many normal pages that 'transclude' the template pages (based on page name).
i.e. some page = "Template: Subject X" and calling page = "Subject X". Calling page contains a {{{{PAGENAME}}}} construct to call the content from "Template: Subject X".
All the templates of A are in a Category (X) and all the normal pages of B are in a category (Y).
Now... ;-)
I want a DPL to list the 10 smallest normal pages from B ... but when I say 'smallest' I mean the smallest 'overall' pages, including the transcluded text from the companion template in A. This overall size is actually the sum of the size of page A and B. Now I figure I can calculate the overall page sizes using a template and the ... I was going to say {{PAGESIZE}} magic word... but I don't find it!
So basically I am stuck.
Is it possible? --Dmb 11:46, 3 June 2007 (CEST)
Question
What exactly what help you? Is there a table column in the sql database the value of which could serve as an input for your calculation? When DPL lists pages it does not look into their contents. When you ask DPL to do processing based on the contents of a page it will go straight forward for the exact purpose (i.e. look for a headline or a template invocation), but there is no inherent "page inclusion resolution" and no size calculation. Gero 12:53, 3 June 2007 (CEST)
Confusion about includematch
I have a task that I think should be perfect for DPL. On my company wiki, we have a template {{todo|username of who should do it|what should be done}}. I'd like to use DPL to show only the pages that have references to this template AND those tasks are assigned to a particular user. After reading the DPL manual, I thought that I should be able to use
<dpl>
uses=Template:Todo
includematch=SomeUserName
</dpl>
However, this seems to list all pages with calls to the template in does not filter based on the username. What's wrong with my method? Thanks in advance. --Gri6507 15:23, 25 July 2007 (CEST)
- Try using includepage={Todo} in place of uses=Template:Todo. -Eep² 06:44, 26 July 2007 (CEST)
- First, you must use something like 'include={Todo}.dpl'
- Note the '.dpl' suffix (any other suffix would do as well). You must create an empty template named 'Template:Todo.dpl'. You could also write some code into that template, but that´s another story.
- And then you must indeed use 'includematch'. But (as the manual says) we expect a 'preg' expression here, which means that you must specify something like 'includematch=/SomeUserName/'. If you have named parameters you must use a regexp which matches the parameter´s name as well as the '=' and surrounding spaces and the argument, of course. If you use unnamed parameters you can only hope that the pattern you are searching for does not occur somewhere else. Again, in both cases you MUST use 'preg' syntax, which means that you need delimiters around the regular expression. It is important to understand that the whole wikitext at the position where your template is called will be used for the match test. So you may use something like '/\|\s*username\s*\|/'. You must be very careful to escape the '|' characters as they have a special meaning within regular expressions. I did not test this, so you may need to experiment a little with escapings. If the wiki text author used a newline between the template parameters you need to make sure that your regexp also covers this.
- I am really trying top help people here. As some kind of thank you it would be nice if you
- put your wiki on the "wikis using DPL" list (although it may not be reachable for the public)
- take your question and my answer and make a contribution in the DPL:FAQ from it.
- Provide a small example to which the FAQ entry links where we can all study the problem.
o.k.?
- Gero 15:32, 26 July 2007 (CEST)
- Thanks for the help. I documented my usage in DPL:FAQ#Getting_pages_with_references_to_templates_with_particular_parameters. --Gri6507 13:58, 31 July 2007 (CEST)
Exclusion of Duplicate Pages
Let me start by saying - Cool extension! A fantastic and powerful addition to MediaWiki...
I have just started using DPL, so this question may very well be a result of ignorance. I have articles that are a part of multiple categories. For example, the "HOWTO: Install the Client" page is a part of the 'Client Solution Center' category, as well as the 'Installation' category. I use the following code to render all pages that are a part of the 'Client Solution Center' category, as well as to show what other categories those pages are a part of.
<DPL> category=Client Solution Center ordermethod=category,pagetouched headingmode=H2 mode=ordered </DPL>
The output is something like:
- Client Solution Center
- HOWTO: Install the client
- Installation
- HOWTO: Install the client
I was under the impression that the distinct parameter was implicitly true, and that it should stop the articles from being displayed twice. This does not appear to be the case. Am I doing something wrong, or not understanding this functionality correctly?
Appreciate the help and hard work!
- 209.139.229.17 16:51, 31 July 2007 (CEST)
Redirects to include pages that link to them?
<dpl> linksto=DPL:Discussion redirects=include </dpl>
- DPL:Bug Reports
- DPL discussion
- Dynamic Page List
- User talk:Gero
- Issue:Imagelinks criteria
- Issue:Modifiedby can return crap result
- DPL:Requests for new features
- DPL:Requests for new features Archive
- User:Subfader
Like Special:Whatlinkshere/DPL:Discussion does (test redirect link to this page), I want an option for the redirects parameter to optionally list all pages that link to redirects as well (without having to manually specify all of them in the DPL statement). Is this possible with DPL and, if not, would you please add it? -Eep² 21:20, 31 July 2007 (CEST)
An example of the problems of manually trying to include all variations of a page with redirects via a template:
{{#dpl:
category=Games
|resultsheader=<h2>Games (%PAGES%)</h2>
|noresultsheader=No games have this attribute yet.
|linksto={{PAGENAME}}{{!}}{{PAGENAME}}s{{!}}{{PAGENAME}}es{{!}}{{PAGENAME}}ing{{!}}{{PAGENAME}}d{{!}}{{PAGENAME}}ed
|redirects=include
}}
Say the page is "cut scene" (with redirects from "cutscene" and "cut scenes"). Now, with this setup, if the page that has this DPL syntax on is "cutscene", then pages that link to "cut scenes", "cut scenees", "cut sceneing", "cut scened", and "cut sceneed" will all show up in the list, assuming the pages are in the "Games" category. However, the 2-word "cut scene" won't show up (unless I manually specify it, but this code is for a template). If DPL truly supported redirects as MediaWiki does, I wouldn't have to create all of these linksto variations...and I don't know of a way to programmatically take a root word and break it up into its syllables. -Eep² 12:51, 7 August 2007 (CEST)
- I do not know how such a feature could be implemented without having to look into the document contents. If somebody can give a SQL query which does the job I will implement the feature. Gero 14:58, 15 August 2007 (CEST)
- Can't you just pull it from SpecialWhatlinkshere.php whch already does it? -Eep² 15:04, 15 August 2007 (CEST)
- The code you mention contains a recursive function which triggers a new SQL query for every redirect page. This means a lot of database load ... Gero 18:18, 15 August 2007 (CEST)
- Well, DPL is already pretty database-intensive as it is, right, so why does it matter? Besides, this doesn't have to be the default "linksto"/"linksfrom" functionality but optionally. I really need this functionality for my wiki, as manually specifying all redirected pages is highly annoying... Perhaps there's a better way to query the database but I don't know--maybe ask the MediaWiki devs? -Eep² 23:49, 15 August 2007 (CEST)
- (Moved from DPL:Requests for new features#redirects include pages that link to redirects)
- I think the problem can be solved with nested DPL queries. Create an inner query which finds all the redirect pages (with redirect=only) to your target page(s) and an outer query which finds pages that link to the pages of the result set of the inner query. Apart from that you would have to add another query which finds the direct links to the target pages (using redirect=exclude). In essence this will do the same as the php code which tracks the redirects. C gives an example how to do it. Gero 20:41, 15 August 2007 (CEST)
- Too complicated. Why can't "redirects=include" actually work intuitively and actually include redirects like it should? A single query should be able to output results like Special:Whatlinkshere does (without require obscure formatting too). -Eep² 05:34, 16 August 2007 (CEST)
- Can't you just create a "redirects=full" parameter, or whatever, that will give all redirect options like Special:Whatlinkshere does? I really need this functionality for my wiki! -Eep² 16:49, 21 August 2007 (CEST)
- Well? -Eep² 09:23, 24 August 2007 (CEST)
- See User talk:Gero#Hello? for further "discussion". -Eep² 15:57, 2 September 2007 (CEST)
Fancy template filtering: is this possible?
I have some pages where I call the same template a number of times. On these pages I call a template that formats an extract from a web site and includes the name of the site and the URL.
Elsewhere I would like use DPL to list all the place where any given website is called via this template.
This appears on a page somewhere:
{{Web citation|
web link=http://www.google.com|
title=Google Home page|
date=June 29, 2006|
source=Google|
extract=What do you expect!}}
{{Web citation|
web link=http://www.yahoo.com|
title=Yahoo Home page|
date=October 12, 2006|
source=Yahoo|
extract=Another search engine}}
This template formats the passed output such that the parameter "source" is used as an internal wiki link. This would then let me have a page for "Google" and another for "Yahoo".
Elsewhere I'd like to find all the pages that have the source = Google.
I can already list every page that uses this template and this also lists all uses of the template on that page (so for this example I'd see both Google and Yahoo listed). I'd like to only include the uses of the template that link to Google. I'd like to put this on a page called Google so that this would then collect all references to Google across my site.
On a page with the Title "Google"
{{#dpl:categorymatch = % | linksto = {{FULLPAGENAME}} | includepage={Web citation} dpl2 }}
Is that clear? Any help would be much appreciated. DPL is fantastic, even if the learning curve is a little extreme.
Brianoflondon 20:11, 6 August 2007 (CEST)
- Try notuses=Template:Yahoo but you'll need to have separate templates for Google and Yahoo in order for DPL to include one (Google) and not the other (Yahoo), in this case. I don't think DPL supports notlinksto for external URLs, but I haven't tried. -Eep² 12:57, 7 August 2007 (CEST)
#DPL reminder
When using DPL with the parser function form, keep in mind that *all* arguments that contained the pipe character “|” should be transformed into a "special" pipe “¦”. Especially the category match parameters, where I tend to forget about this rule of thumb. Using the debug level when testing should be a good idea, too. - 82.249.32.133 16:16, 16 August 2007 (CEST)
all namespaces
How do I get a list of all namespaces? -Eep² 12:46, 29 August 2007 (CEST)
Answer
Unfortunately there is no built-in way for that. You could create a page with identical name in each namespace and call it, say, 'About this namespace'. A DPL query with a titlematch on that name would then deliver exactly all these pages. Using the %NAMESPACE% variable you get the list you want. Not really nice, though ... Gero 13:22, 29 August 2007 (CEST)
- Well, don't you think DPL should be able to do that inherently like it can with categories and pages? -Eep² 13:29, 29 August 2007 (CEST)
Show Articles in one Category by Sortkey
I just created these 3 Articles which are categorized in a different order than the title names:
{{#dpl:category=VolkoV}}
How is is possible to sort the Articles in the categorized order?--VolkoV 18:37, 31 August 2007 (CEST)
- DPL is extremely powerful. To use its power you will have to spend some time with the manual. I changed the queries on your homepage; now the list is ordered by categories. There are even two variants of how to do it. With mode=userformat there are further possibilities - you could even create tables which can be dynamically sorted by a click of the user. Have fun! Gero 22:39, 31 August 2007 (CEST)
Thanks, I extended the example, Page C is categorized as A as well under VolkoV as under TopVolkoV. In this case, using your Code produces a double Entry in the List. And this ist exactly what happens in the productive System as well. Is there a workaround? We use DPL to produce Lists with the Links to Pages of a category an a small description which is read in the template. This far it works pretty good, only the sorting makes problems.--VolkoV 07:51, 1 September 2007 (CEST)
- I figured it out by myself: I needed to use the "+" before the category name. It works now, as I wnated to...--VolkoV 08:39, 1 September 2007 (CEST)
notcategory/notnamespace
Why can't these parameters accept the "OR" separator (|)? -Eep² 13:08, 1 September 2007 (CEST)
Examples using other extensions
Need more of these to show that DPL can be just as good as Semantic MediaWiki--if not better--at listing relationships between articles (like which articles have populations over/between/under certain amounts, etc. I believe this is possible using nested DPL queries that use the math parser functions. -Eep² 05:27, 4 September 2007 (CEST)
Category lists that show content amounts
I want to create standard MediaWiki category lists but with the amounts of articles/subcategories in each member in parentheses:
Articles (2)
A (2)
|
B (1)
|
C (1)
|
resultsheader does the "Articles (2)" part but how do I get each member (and beginning letter/symbol of that member group) to show how many articles/subcategories are contained within them? If the member is an article, I want to show how many articles link to that article (as I currently do for each article on its page). See http://www.tnlc.com/wiki/index.php?title=Category:Templates for an example of this:
{{#dpl:
namespace=Template
|mode=category
|ordermethod=titlewithoutnamespace
|shownamespace=no
|rowcolformat=width=100%
|redirects=include
|resultsheader=<h2>Templates (%PAGES%)</h2>
|noresultsheader=<h2>Templates (0)</h2>''No templates.''
}}
-Eep² 13:12, 4 September 2007 (CEST)
Reply
This would definitely have to become a hardcoded feature in the php source. Gero 19:28, 4 September 2007 (CEST)
- Which PHP source, MediaWiki or DPL? Is there a way to do this "manually" (i.e. without mode=category) in DPL at this time? -Eep² 00:33, 5 September 2007 (CEST)
- The DPL source.
Replace delimiter-separated lists with links
Is this possible with DPL? See mw:Extension_talk:StringFunctions#Delimiter-separated_lists_into_links for more info. -Eep² 15:43, 11 September 2007 (CEST)
- Not with DPL. But you can try to use the StringFunctions extension. The version here in this wiki is slightly modified and uses preg_replace() and that should be able to do the job. Read the php manual on preg_replace. I can make the modified StringFunctions version part of the download archive if you succeed. --Gero 21:21, 11 September 2007 (CEST)
- If I succeed at what? How about getting the preg_replace in the actual mw:StringFunctions extension too? -Eep² 23:06, 11 September 2007 (CEST)
- If you want to use a concept like regular expressions you will have to invest some time in reading manuals! StringFunctions extension gives a demonstration of what you can do. I put the source code of StringFunctions there because I got the impression that the maintainers of the official code are somewhat reluctant about adding regexp syntax to the extension... --Gero 08:14, 12 September 2007 (CEST)
- I've told you before I'm not a programmer, and can't stand (or sit) doing it. Anyway, I'll try your version; thanks. I need to nest the replace in an {{#if:}} but the default StringFunctions extension doesn't render it if I try something like {{#if:{{{actions|}}}|[[{{#replace:{{{actions}}}{{!}}, {{!}}]], [[}}]]|?}} but it doesn't work (with the {{!}} or just a |). The result is [[{{{actions}}}|, |]], [[}}]] (as-is in plaintext with no parameter replacement or formatting). Do you know why? Using your version I'll have to nest yet another replace so I don't know if that will work inside an if either... -Eep² 09:03, 12 September 2007 (CEST)
- OK, I tried using {{#replace:{{#replace:|{{{actions|}}},|/ *([^,]+)/| [[\1]]}}|/,$/|}} but the result is blank with |actions=climb, dive, grab edge, jump, pick up, pull, push, roll, run, shimmy, shoot, sidestep, swim, vault, walk in an article template field. -Eep² 23:12, 12 September 2007 (CEST)
- Hello? -Eep² 12:01, 14 September 2007 (CEST)
- My dear friend, I am not here to teach somebody programming who says he can´t stand being a programmer and at the same time wants to do things which can only be done with that special attitude of modestness, concentration and thoroughness which is always required if you want a computer make to do what you want it to do.
{{#if:{{{1|}}}|{{#replace:{{#replace:{{{1|}}},|/ *([^,]+)/| [[\1]]}}|/,$/|}}|}}
- Gero 18:07, 16 September 2007 (CEST)
- Well, it's not like I'm not trying, Gero. Not everyone's cut out to be a programmer--and I've never claimed to be one. OK, so the only thing I had wrong was the "|" after the second {{#replace:. However, now there's no longer a space after the comma (which I tried adding a " " and even " " to after the commas but the result is still no space--and a trailing comma at the end, which I don't want).
- I see you added a DPL:FAQ#I want the article list separated by comma that uses DPL but how do I get this using regular expressions as above? I'm still getting a space before the first word in my game template. -Eep² 16:49, 23 September 2007 (CEST)
More comma problems
Trying to get just a plain list of pages without links to them via:
{{#dpl:namespace=
|linksto={{PAGENAME}}
|redirects=only
|format=,%PAGE%,
|resultsheader=<ul><i>Redirects:
|resultsfooter=</i></ul>
|noresultsheader=<div style=display:none>
|noresultsfooter=</div>
}}
...but the commas aren't getting rendered. How do I do it? -Eep² 14:01, 16 September 2007 (CEST)
Answer
I think there is an example for this problem in the FAQ. Use , to produce a comma (see the source of this article!):
format=,%PAGE%, ,
- Gero 17:52, 16 September 2007 (CEST)
- Tried that but then there's a comma at the end of the last result too, which I don't want. How do I fix that? -Eep² 07:21, 17 September 2007 (CEST)
- OK, the FAQ (link in previous section) explains how using mode=inline|inlinetext=, (non-breaking space code not shown, for some reason) but what if I don't want the results to be links? I'm trying to make redirects list and having the results links is pointless since they redirect back to the same article anyway... -Eep² 16:59, 23 September 2007 (CEST)
Indeed inlinetext only works for standard output, not for 'userformat'. You must add a comma in the format statement and then remove the last comma like this:
...Nig1,Nig2,Nig3,Nig4,Nigeria,Nigunda,Nigunda Test...
- or with an additional blank
...Nig1, Nig2, Nig3, Nig4, Nigeria, Nigunda, Nigunda Test...
- Gero 17:03, 27 September 2007 (CEST)
- I tried this but it still leaves the trailing (end) comma:
{{#replace:{{#dpl:namespace=|linksto={{PAGENAME}}|redirects=only|format=,"%PAGE%", ,|resultsheader=<ul><i>Redirects: |resultsfooter=</i></ul>|noresultsheader=<div style=display:none>|noresultsfooter=</div>}}|/,$/|}}
- —Eep² 23:51, 27 September 2007 (CEST)
A convoluted problem (DPL Recursion?)
In the manual where it talks about special chars, there's a mention of nesting DPL calls and DPL recursion, but there doesn't seem to be any elaboration or example of what this means/what you can do with it.
I'm working on a project at the moment that I'm not quite sure how to approach. For example:
A dish is made up of one or more recipes that in turn are made up of ingredients.
In this case, I'd be wanting to find all of the dishes that used recipes that contained a specific ingredient so that I could have a list of dishes that contained that ingredient.
How I'm currently getting recipes using a particular ingredient is something like the following:
{{#dpl:
namespace = Recipe
| uses = Template:Ingredient_Item
| include = {Ingredient_Item}:Ingredient
| includematch = (Potato)
}}
Is there a way to grab any dish pages that refer to those recipes (at this stage, I'm expecting to use a "Recipe_Item" template in the same way that I'd use Template:Ingredient_Item|Potato in a recipe)? Failing that, is there a way that I can put the above DPL call into the linkto parameter of another call?
- Cheese 05:25, 19 June 2013
Reply
I think DPL is powerful enough to solve that kind of problem structure. You need two different articles, one of them contains the 'inner' query, the other on contains the 'outer' query. The result of the innner query is formatted in a way that it can be used as an argument to the 'linksto' parameter of the outer query. I think you can learn from a short example I gave some weeks ago. It has the belletristic name of C resp. CC. It would be awfully nice if you could turn that example to something with dishes, recipes etc. That would really justify a better name like "Example with nested DPL queries" ;-)
If you run into problems I will try to help as the kind of application you have in mind is exactly what I often face and where I want DPL to be helpful.
- Gero 17:00, 2 October 2007 (CEST)
Success
Many thanks, Gero
After having a bit of a play around, I've come up with this in my ingredient page ("Potato" would be replaced with PAGENAME):
{{#dpl:
namespace = Recipe
| uses=Template:Ingredient_Item
| include={Ingredient_Item}:Ingredient
| includematch = (Potato)
| replaceintitle=/ /,_
| format = ,²{DPL_Sub_Query¦NamespaceName=Dish¦TemplateName=Recipe_Item¦ParameterName=Recipe¦Value=%TITLE%}²,}}
and this in Template:DPL_Sub_Query:
{{#dpl:
namespace = {{{NamespaceName}}}
| uses=Template:{{{TemplateName}}}
| include={{{{TemplateName}}}}:{{{ParameterName}}}
| includematch = ({{{Value}}})
}}
Obviously I'll be making more specific templates for the project I'm working on (the above is just to make sure I'm understanding what's happening). Once I've got it ironed out a bit more, I'd be happy to help adapt it as an example.
Also, Eep² has some questions that are hiding away at Talk:C
- Cheese
Matching and Output
In my above dish/recipe/ingredient example, I'm using the include parameter so that I can use regex to match against it. Since I'm only getting the dishes that have potato in them, it's a little redundant to also have "Potato" in the output.
Currently I'm using the format parameter to hide it with HTML comments. Is this the best method for getting what I'm after? Is there a way to match using regex against content without including it?
| format = ,\n* [[%PAGE%|%TITLE%]] «!--,--»
- Cheese
- Using html comments is a nice trick, although not very clean ;-).
- Did you have a look at the "table" and "tablerow" commands? If you specify an empty parameter at tablerow the contents will be suppressed. But you probably will get an empty column in the table...
- Currently there is a conceptual link between "include" and "includematch". The regexp is applied to the parameter list as a whole. So you can match on parameter1 and include parameter2 of the template. But you must at least include one parameter.
- Gero 11:25, 3 October 2007 (CEST)
Listing all articles in category including the current page?
Let me explain best I can. I have a category 'Location' which contains:
- Location A
- Location B
- Location C
- Location D
Every one of these pages has a navigation template included, to make it easy to navigate around the content. The navigation is generated using <dpl> category=Location </dpl>. This is great, for the most part, but if it is included, ie, from the page Location B, the list will not include that title, thus the navigation listing becomes:
- Location A
- Location C
- Location D
While it may seem strange, for the sake of the list staying the same at all times, I really want it to include every page including 'Location B' even though it would just a title name bolded. Is it possible, or can I change a line of code to stop the current page name being filtered out from the results?
Thanks, Babylon2x 07:28, 9 October 2007 (CEST)
Reply
There are good reasons why DPL blocks the current page from being part of the result set. These reasons have to do with the transclusion of contents and possible indirect recursions in complex queries. There is a well document "if statement" near line 2655 which you could comment out if your query is rather simple in its structure. But I would advise to introduce a new commandline parameter which might be called "skipthispage=no" (default being "yes"). This would allow you to use the parameter only in that very DPL statement.
- Gero 21:16, 9 October 2007 (CEST)
... Well, it was an easy change so I added that parameter to the official version here. In return it would be nice if you could test some of the test queries in this wiki with the new parameter set to "no". If the query still works you can leave the parameter there. Let us know here if you run into trouble.
- Gero 22:00, 9 October 2007 (CEST)
Thanks!
I'll update and get testing ;)
Listing redirects and where they link to
I would like to list all redirects in a category, but also I'd like to know where each redirect goes to. I know how to use DPL to create the list of redirects, but I am not sure if it's possible to list where each redirect goes.
The end result would ideally be:
Acronym Title is an acronym for Acronym Title Redirect Title
Solution
See DPL:FAQ and C / CC. I know that C annd CC are strange names. And they demonstarte how to solve the inverse problem (linksto with redirects). Maybe you want to invest a little time and create an example which is more easily understood?
- Gero 23:54, 22 October 2007 (CEST)
Examples
Okay, maybe this shows a little bitter what I was looking today:
http://semeb.com/dpldemo/index.php?title=Listing_Redirects_and_Location
I imagine one way to do it is by setting these redirects up to use a template. Being able to grab the #REDIRECT value on a page would be handy, though. There may be a way already that I'm overlooking. :)
Babylon2x 01:57, 23 October 2007 (CEST)
Solution (2)
See your Listing Redirects and Location example to understand how to do it. Gero 08:47, 23 October 2007 (CEST)
Output depending on word in template parameter
I am trying to filter out some out of a lot of pages with the same template, where one special parameter has a desired word in a comma-seperated list. For example I want to output this page, since it matches the regular expression /Rome/:
Page A {{SampleTemplate|Param=Berlin (Brandenburg Gate), Rome (Collosseum), Paris (Eiffel Tower), London (London Bridge)}}
but not this one:
Page B {{SampleTemplate|Param=Prague (Hradschinn), Amsterdam (Warfts), Paris (Notre Dame)}}
Is this possible?--VolkoV 21:08, 21 November 2007 (CET)
- Alternatively: If I use
include=SampleTemplate.dpl
- is there a way to give a parameter, let us just say {{{%City%}}} to the SampleTemplate.dpl? That way I can use my improved version of the ParserFunctions-Extension which understands regular expressions.--VolkoV 08:11, 22 November 2007 (CET)
- The includematch statement is what you are looking for. Read about regular expressions beore using it (in case you have no experince with regexp syntax). Be careful to escape pipe characters ifyou wantto us them within your regexp. Gero 15:33, 22 November 2007 (CET)
- The phantom template is always called with the original parameters plus some general parameters about PAGE, TITLE, USER ... So if your parameter is named City you can just use it with standard notation (triple curly braces around City). But it would be rather ineffecient to call the template each time and let it then decide whether it wants to output some text or not. INCLUDEMATCH is the better way to do it. Gero 15:33, 22 November 2007 (CET)
Thanks, the includematch works fine! Still I'm looking for a way to hand over an extra parameter to the phantom template. I extended the above example. As you can see there are annotations in brackets, so if I'm using DPL with includematch to search the two pages above for /Paris/, I would like to hand over the parameter "City=Paris", so that inside the template I could use it in a preg_replace to find out the extra-information in the bracket and produce an output like
is that possible somehow? I don't want to write A template for every city...--VolkoV 08:50, 23 November 2007 (CET)
Answer
The value of the includematch parameter would contain the string ('Rome' in your example), but
- DPL parameter values are not being passed to phantom templates
- the parameter contains a complete regexp and you would only want to use the string 'Rome'
The solution I usually take in such situation is quite simple and is based on Extension:Variables. I set a variable (using #vardefine:) in the template contanining the DPL statement with the value I need (because in that template the value is normally known) and then in the phantom template I grab the value using #var:. Normally it is sufficient to set the variable outside the DPL statement (BEFORE it, of course). But you could even set the value inside the loop within the format statement. You would have to use ²{#vardefine:....}² there to make sure that it is executed WITHIN the loop and not once (statically) before iterations start. This is only useful, however, if you want to pass a value which is calculated dynamically by DPL like %NR% or so.
Is that clear to you? Otherwise you could give an URL to the resp. page in your wiki...
- Gero 13:25, 24 November 2007 (CET)
Translate Section tags into template call
I've got a tricky problem that I think DPL can almost, but not quite, solve. What I would like to do is to take a page which has content marked with LST-style <section> tags, and transform it into a template call. The catch is that I do not want to explicitly specify the section names in the DPL call. Rather, I want it to process all of the section tags in the target page, no matter what they are.
I think that there are two capabilities still needed to make this work:
- %SECTION% codes in 'secseparators' statements would need to work for <section> tags, as well as chapter headings.
- 'include' statements would need to allow some kind of wildcard, to mean 'all sections'. Perhaps '**' ?
Example
I'd like to have a page containing:
The USA flag has <section begin="stripes">13<section end="stripes"> stripes and <section begin="stars">50<section end="stars"> stars.
...and use a DPL call like the following:
<DPL>
title=MyPageTitle
format = ,{{flag,}},
# I want this next line to mean "Do this for all sections"
include = **
# This next line would work, if %SECTION% worked for section tags as well as chapters.
secseparators = ¶|%SECTION%=
</DPL>
...to produce output like:
{{flag
|stripes=13
|stars=50
}}
Is there a way to do this now? If not, I'll just say that this would make DPL much more powerful. --Sacolcor 06:27, 7 December 2007 (CET)
Currently there is no way to do this. Your problem sounds like a one-time migration task. I would consider to export the affected pages to XML and write a php or perl script exactly for that purpose ...
- It isn't a one-time migration; the templates I'm using produce output pages with a lot of complicated formatting, and the input pages are being changed all the time. I'm trying to find a way to automatically call the templates with the correct parameters (one for each tagged section), so that I don't need to change them when the content of the pages they're looking at changes.
The problem I see with enhancing DPL in the way you proposed is the fact that sections can overlap and can be nested as far as I know .... Gero 21:25, 7 December 2007 (CET)
- This is true, but I don't think that it is prohibitive; DPL could just get a list of each section tag along with its contents, and merge (concatenate) any duplicates. It should be fine as long as the sections are output in a standard order (probably the order of their begin tags). Nested or overlapping tags could cause some content to be duplicated, but that seems okay to me. The advantage of allowing this is that it's very flexible, and could be used to generate reports that do not need to have their columns explicitly specified. --Sacolcor 22:51, 7 December 2007 (CET)
- Release 1.6.3 offers a simple way to catch all (non overlapping) sections as pairs of section label and contents. Maybe this helps? It´s hard to do more ... Gero 13:14, 9 December 2007 (CET)
- Thanks very much for working on this. I've downloaded it and run some tests, and I think there may be a couple bugs:
- First, could you have it place the 'secseparators' between each of the sections?
- Second, could you make the section name available in the %SECTION% variable?
- Finally, could you leave out the section name and the '::'? If the above two are done, I can format the result myself using secseparators.
- Thanks very much for working on this. I've downloaded it and run some tests, and I think there may be a couple bugs:
If you would like me to test the new version, my email address is in my preferences; either email me directly, or send me wiki mail. Thanks again! --Sacolcor 23:31, 9 December 2007 (CET)
Issue with category and rowsize
I want to list categories, but with multiple columns per category.
I have the following code:{{#dpl:category=cat1{{!}}cat2{{!}}cat3
|notcategory=templates
|linksto={{PAGENAME}}
|ordermethod=category,sortkey
|headingmode=H2
|order=ascending
|mode=userformat
|listseparators=\n{¦\n¦-,\n¦%PAGE%,,\n¦}\n
|rowsize=4
}}
This seems to work, except for the rowsize, which should repeat the startall and endall bits every four rows does not.
(I would also like to supress a category, in this case the articles all share a common category (catmaster) which is also in the output list, I don't mind duplicates so if an article is in cat1 and cat4 I don't mind cat4 appearing...) Dcorrin 18:32, 13 December 2007 (CET)
Reply
Rowsize does not do what you want. But there is a workaround. You have to add the "rowfeed" yourself. Pay attention to the escaping mechanisms used!
{{#dpl:
|headingmode=H4
|category=Test
|ordermethod=category,sortkey
|order=ascending
|mode=userformat
|format=\n{¦class=wikitable\n¦-,\n¦%PAGE%,\n²{#ifeq:²{#expr:%NR% mod 4}²¦0¦\n²{!}²--}²,\n¦}\n
}}
See the output below. ~~~~
DPL Example
| Test table |
DPL Manual
| DPL:Manual - dplmatrix |
Tag Event2
| Test section inclusion |
Test
| 2007/04/28 my event name | |||
| :Category:African Union member states | Calendar | :Category:Cities | :Category:Countries |
| DPL:Manual - dplmatrix | Events | :Category:Events | Listing Redirects and Location |
| Resultsheaderwithcolumns | Test | Test addcategories | Test addcontribution |
| Test addfirstcategorydate | Test adduser | Test article structure | Test cat listing |
| Test category hierarchy | Test category listing | Test columns | Test createdby |
| Test date formatting | Test debug | Test escapelinks | Test goal |
| Test headingmode | Test identical chapters | Test ignorecase | Test imagecontainer |
| Test includematch | Test includetrim | Test linksfrom | Test linksto |
| Test matches | Test matrix | Test mode category | Test numberOfArticles |
| Test offset&count | Test onlyinclude | Test redirects | Test regexp |
| Test resultsheader | Test revisions | Test section inclusion | Test shownamespace |
| Test Sort order | Test subcategories | Test table | Test title |
| Test uses | Test what links here | Test what links here 2 |
Test onlyinclude
| Test onlyinclude |
Inverse Tree
A number of our wiki users have requested the following feature. Both articles and categories can be added to a number of categories. Traversing this structure could become cumbersome since this "linking" goes both in the breadth and the depth. To facilitate movement within categories, our wiki users have requested to see a list of all categories linking to the page they are viewing, and all categories linking to those categories, etc. In other words, they want to see an inverse tree where the root is an article they are viewing and the nodes are all categories linking to this article either directly or indirectly (if you think about it, this is kind of a self-centered view of the wiki world :-) but, hey, that's what they want to see).
It seems like something like this should be possible with DPL, but I cannot figure out how. Can someone please help?
- You can use goal=categories. You must use a nested subquery to get the 'secondary' categories pointing to the 'primary' categories. It should not bee too complicated to do that. Use title= together with the PAGENAME macro.
In fact it require sonly three lines of code to produde an indented tree, see Test goal.
- Gero 00:42, 31 December 2007 (CET)
Complex Table
I currently have a somewhat complex table which looks like this:
{| border="1" cellpadding="2"
|-
! colspan=6 | customer || company
|-
! rowspan=2 | name
! colspan=5 | contact
! rowspan=2 | account manager
|-
! name !! e-mail !! phone !! mobile !! language
|-
| BushHouse || Kathy London || kathy.london@bushhouse.uk || 01 57 59 11 || || ||
|}
I've created a page named "Infobox CU Bushhouse", which holds the "Infobox CU Customer Info" structure defining all the variables. I can create a simple table like this:
{{#dpl:
|category=Customers
|titlematch=Infobox CU%
|include={Infobox CU Customer Info}:link:ctct_name:ctct_email:ctct_phone:ctct_mobile:ctct_lang:act_mgr
|table=class=sortable border=2 cellpadding=2,-,customer name,contact name,contact_email,contact_phone,contact_mobile,contact_language,account_manager
}}
Is there a way to make a similar more complex table in dpl? (If you know a better place to ask this question, please let me know.) --Hvdeynde 18:21, 10 January 2008 (CET)
The 'table' parameter only allows to define 'standard' tables. But you can use the format statement (you put the header declaration into its first parameter) and a phantom template, see the include statement.
- Gero 08:59, 11 January 2008 (CET)
Limit to only files/images/uploads
Hi, we have quite a few uploads to our wiki and i would love to be able to create different lists to these files. Things like Uploaded files by XXX or files that live in the category. Is this possible please? Sorry if I have missed something on the site, I have had a good look about.
Thank you
--Dogsbody 17:08, 31 January 2008 (CET)
Of course, I always forget about the namespaces! Thank you very much for your help
--Dogsbody 16:05, 1 February 2008 (CET)
Reply
Did you try something like:
<dpl> namespace=Image ordermethod=lastedit,title adduser=true addeditdate=true order=descending createdby=Roc michael </dpl>
Extension:DynamicPageList (DPL), version 2.01 : Error: Wrong 'namespace' parameter: 'Image'! Help: namespace= empty string (Main) | Category | Category_talk | DPL | DPL_talk | Dpldemo | Dpldemo_talk | File | File_talk | Help | Help_talk | Issue | Issue_talk | MediaWiki | MediaWiki_talk | Talk | Template | Template_talk | Test | Test_talk | User | User_talk | Wgraph | Wgraph_talk.
Performance / Caching
Hi, I've whipped up some custom javascript to implement pagination so that I can fit more results in a smaller amount of screen space. To achieve this, I added 3 different DPL queries to a single page, with only 1 being visible at a time. The problem that I'm having is the page loads extremely slowly, which is not good since I want to put 2 more similar content areas on the same page (e.g. an extra 6 DPL queries).
Our wiki is not overly large - about 1,500 content pages. I've enabled caching, but the page is still unacceptably slow to load, and caching is not ideal for the type of content I want to report on anyway. Below is the markup for one of the queries - the other two are the same apart from an 'offset' parameter.
{{#dpl:
|skipthispage = no
|adduser = true
|addeditdate = true
|namespace = {{!}}
|count = 5
|ordermethod = lastedit
|order = descending
|userdateformat = j-M y
|allowcachedresults = true
|format = ,\n* <div style="border-bottom:1px solid #F0F0F0;padding-top:3px;">'''[[%TITLE%]]'''<br />''<span style="font-size:smaller;color:#666666">by [[User:%USER%{{!}}%USER%]] ( %DATE%)''</span></div>,,
}}
Does anyone have any suggestions as to how performance could be improved? Any help would be appreciated! --- Dave 09:36, 14 April 2008 (CEST)
Reply
You could:
- ... use debug=3 and look at the SQL statement; does it contain unnecessary things?
- ... run that statement in phpmysql or some other tool directly; thus you could see if most of the time spent comes from the database
- ... have only one or two DPL statements on your page. Using a suitable 'format' statement your DPL query could generate JAVASCRIPT code instead of wikitext. You could fill a Javascript data table and use Javascript code to scroll in the results
- ... use Ajax with the SimpleForms extension
- ... store the complete result page in cache and avoid rebuilding it if the contents is reasonably recent; normal caching mechanisms are not that clever ..
- Gero 17:57, 14 April 2008 (CEST)
Reply to Reply :)
Thanks for the suggestions! I did manage to increase performance slightly by generating a single, larger list and modifying my javascript to be able to show/hide individual results.
I also had the idea of using AJAX to only render the different result 'pages' as they are needed - AJAX sounds like the only solution that would give significant performance gains. The biggest plus would be that the rest of the page wouldn't be held up while waiting for the DPL queries to finish. I'm going to look into this when I get a spare minute since I'm not all that familiar with AJAX.
On a side-note - do you know if it is possible to 'chain' AJAX elements? e.g. load DPL #1, then start loading #2 once #1 is done, etc. --- Dave 05:58, 16 April 2008 (CEST)
Include templates containing a slash
I would like to include pages containing a slash (e.g. Template:Tpl/asdf). I tried the following:
include = {Tpl/asdf}
and got a php error message: Warning: preg_split() [function.preg-split]: Unknown modifier 'a' in /path to mediawiki/extensions/DynamicPageList/DynamicPageList2Include.php on line 393
Is there another way to do this? --J* 10:29, 22 April 2008 (CEST)
Reply
We have a page Abc which includes Template:Abc/x123. A query to get all inclusions of Abc/x123 would look like this: As you can see it works fine
<dpl>
titlematch=Abc
include={Abc/x123}
</dpl>
- Abc
- This is template Abc/x123. It was called with value 'a value'.
Combining linksfrom and linksto
I am trying to get a list of all pages within certain categories that link to the pages linked from the current page, like this:
{{#dpl:
|noresultsheader = No similar relationships were found. Why not [[Relate_entries|add a new relationship]]?
|category = {{#dpl: namespace = Category | category = Relationship | mode = inline | inlinetext = ¦ }}
|linksto = {{#dpl: linksfrom = {{{1}}} | format = ,%TITLE%¦,, | distinct = strict }}
|ordermethod = category,title
|headingmode = unordered
|distinct = strict
}}
However, this returns some pages which link to the pages linked from the current page, but are not in the categories listed. Any ideas? Dillybravo 22:27, 20 June 2008 (CEST)
Examples, List content, null results
I'm still digging through the manuals and trying to understand it all, so if I missed these, my apologies.
First, are there other sites that show more examples of DPL queries and results? I keep banging my head on the examples listed trying to figure out how to get what I need done. Found other DPL based sites, but short of tearing apart the pages to attempt to see how it was done, which I can do, I haven't been finding a lot of reference material.
Second, one of the things I would like to do is to be able to set up a page selection of pages using a template, and to output the results using a parameter of that template INSTEAD of a page name. So for example, if I have a group of pages in a category, and one of the parameters in the template for those pages is 'Name', I'd like the output to list the value of the parameter, which would then link to the actual page result. Is that possible, and if so, how would that work?
And lastly, I can't seem to find the means to suppress the "%DPL-1.7.4-WARNING: No results!" message when there are null results. What am I missing? see Manual Talk Page
Thank you
glitch25 22:03, 9 September 2008 (UTC)
maximum article age
hello,
is there any way to select only arcitles that are fe. not more than 3 months old?
i have found i can tell DPL to use exact date/time, but i need dynamic age fe.
donotdisplayarticlesolderthan=3m
or smth like this
Reply
This is very easy to do using mediawiki´s built-in variables. Just use CURRENTDAY, (CURRENTMONT+9)%12 and CURRENTYEAR. You need to use an extension like "expr" for the arithmetic expression which understands the modulo operation. o.k. ? Gero 22:21, 19 September 2008 (UTC)
re re
thanks, works fine, but only if i use
{{#dpl:
|firstrevisionsince={{#expr:{{CURRENTTIMESTAMP}}-00000300000000}}
...
}}
is it also possible to use it combinating this
<dpl>
firstrevisionsince={{#expr:{{CURRENTTIMESTAMP}}-00000300000000}}
...
</dpl>
i want to use the new parser. thanks for hints :)
schizofrenic re
hello myself
i have just made an patch to allow firstrevision specify dynamic since like
firstrevisionsince=-3m
this means 3 months before current day (possible options are day(d), month(m), year(y)), you can find the patch here[1] also with the feature, adding parameter
addfirstparagraph=true
adds first paragraph from inserted page
Make sums
I need to make sums of collected pages whith dpl.
How do it? Exemple:
http://wiki.servas.it/index.php?title=Conto_Matteo_Pedani
In this test page I need to add the sum of euro from banca and subtract the euro to fornitori and put the result below the table
--Matteo Pedani 22:48, 23 October 2008 (UTC)
- I suggest that you have a look at the PLOTICUS extension which is provided here. See the example at Ploticus Demo. Notet that there is much more you can do with ploticus. WikiSysop 05:46, 26 October 2008 (UTC)
Squelch "some" headingmode headings?
I am using headingmode with ordermethod=category,title to generate a categorized list of articles:
<dpl> category=Database programming cookbook recipes ordermethod=category,title headingmode=H3 columns=3 </dpl>
But I want to omit some category sections (like "Database programming cookbook recipes", or utility categories like "Pages with custom CSS") from appearing in my list. I.e. I want all "Database programming cookbook recipes" articles, but I want to show only some of the category headings, and hide others. Any thoughts on how to do this? --tedo 20:52, 18 November 2008 (UTC)
DPL doesn't update
We wrote a template which includes a DPL-list with all pages that link to the specific page on which the template is used. For that we put the following line into the template.
- {{#dpl: category = Vergleich | linksto = {{FULLPAGENAME}} }}
This worked fine until recently. But now the dpl-list doesn't display the results anymore (see e.g. http://de.wiki-products.org/MEDION_Seniorenhandy_SP1200 ). I have no clue why it doesn't work. Any ideas? My best, --Gollum2 13:35, 21 December 2008 (UTC)
Image links
Hi,
I need to make a list of images and the pages in which they are used.
I tried just including the section #Links (or #filelinks as it's refered to in common.css), but it's just a system message, so it's not working. Any ideas?
- Well, we have several hundred images that all starts with "Form_" followed by a number. Ie Form_6010456.png. The page I'm creating here is an overview of all these and I want to include links to the articles in which each picture is used.
- As such:
Form Used in article(s) Form_601024 Known bugs in form 601024, Change log v5.1 Form_230053 JDF Setup
- I'm not sure as to exactly how imageused will be able to do this, since I can't really list all these images as a parameter.
- Martinfs 10:14, 14 August 2009 (UTC)
Image Links
You can use an "inner DPL query" to generate the list of images; You use that query as an argument to the outer query:
Extension:DynamicPageList (DPL), version 2.01 : Warning: Wrong 'imageused' parameter: '<p>Extension:DynamicPageList (DPL), version 2.01 : Error: Wrong 'namespace' parameter: 'Image'! Help: <code>namespace= <i>empty string</i> (Main) | Category | Category_talk | DPL | DPL_talk | Dpldemo | Dpldemo_talk | File | File_talk | Help | Help_talk | Issue | Issue_talk | MediaWiki | MediaWiki_talk | Talk | Template | Template_talk | Test | Test_talk | User | User_talk | Wgraph | Wgraph_talk</code>.</p>'! Using default: . Help: imageused= .
Listing each referring article in a separate row easily allows to sort the list by image or by article.
Gero 10:53, 14 August 2009 (UTC)
- That was actually what I had been trying, but I wasn't sure about the syntax for inner queries. This is perfect, thanks a lot!
- Martinfs 15:59, 14 August 2009 (UTC)
DPL Recursion, part 2?
Hey guys, you've got an awesome extension here. I've been working with it the past few days, but ran into a problem nesting DPL templates. Before getting into the giant chunk of text I posted below, I have a guess at what my problem is, but I'm not sure.
Is it possible to nest DPL templates 3 deep? First template calls another, which calls another.
The reason I think that might be my issue, is because when I copy the contents of the top template into a test page and use it without a template (only nesting 2 times that way) and it works fine. But when I call it in the template, it gives me and error.
I'm getting this error...
Expression error: Unexpected < operator
There aren't any '<' in the code at all (the HTML comments below were added when posting here, to clarify). So I think it's got to do with my use of the extension, not my code itself.
My situation
What I've got is a bunch of items. Some of these items are used to create "constructed" items. A "constructed" item can have 2 or more "component" items, that when combined, creates the "constructed" item. As an additional hitch, a "constructed" item can be a "component" of another "constructed" item.
So, lets say you have itemA and itemB (both basic items), and they combine to form itemC (constructed item, with itemA and itemB as components). Then you can go one step further, and get itemD. itemC (constructed) and itemD (basic) combine to create (itemE, with itemC and itemD as components). (Hope that's clear)
Each "basic" item has a cost in a template on it's page. I want to be able to automatically calculate ANY item's cost. Obviously, for it's very simple for a basic item.
Template GetRegularItemCost
{{#dpl:
|title = {{{item}}}
|include = {itembox}:cost,{recipebox}:cost <!-- item could be an item, or recipe, so we get either cost, still a single item -->
}}
To get a "constructed" item, it's a bit more work, but there are two different types of "constructed" items, as described above. There's an item "constructed" of only basic items, also simple.
Template CalculateRecipeItemCost
{{#dpl:
|category = Category:Components of {{{item}}} <!-- this indicates that the item is constructed -->
|include = {Itembox}:cost,{recipebox}:cost
|listseparators = ²{#expr:,+,,}² <!-- using #expr to calculate the items cost -->
}}
There are also "constructed" items that contain other "constructed" items and/or basic items. This template combines the above two for this situation.
Template CalculateConstructedItemCost
{{#dpl: <br>
|category = Components of {{{item}}} <!-- get all components of the item, constructed or basic -->
|listseparators = ²{#expr:, + ²{#ifexist: Category:Components of %TITLE%{{!}} <!-- check component type, constructed or basic -->
²{DPLCalculateRecipeItemCost{{!}}item=%TITLE%}²{{!}} <!-- add all constructed components costs -->
²{DPLGetItemCost{{!}}item=%TITLE%}²,}²,}² <!-- add all basic component costs -->
}}
So, I have a template that will work for basic items, and a template that works for both types on constructed items. I want to combine them, so I have one template that works on ALL items. Seems easy enough... but it doesn't work.
Template GetItemInfo <!-- simply checks to see if its constructed or basic, and calls the required template -->
{{#ifexist: Category:Components of {{{item}}} | {{DPLCalculateConstructedItemCost|item={{{item}}} }} | {{DPLGetRegularItemCost|item={{{item}}} }} }}
Any help would be great, thanks! --Workdawg 13:45, 27 August 2009 (UTC)
Short reply
There is no limitation to nesting DPL queries - except resource consumption, of course.
It looks as if you have an open comment block in your second query where it says "using #expr to calculate the items cost". The error messages also points into that direction. Apart from this I see no obvious reason why it should not work. Maybe you could use ¦ instead of the !-template, but that is just for ease of readability.
You should know that there was a recent change in MediaWiki which now forbids direct or indirect recursion of template calls. So, if you need recursion, you MUST create an identical copy of the template with the recursive DPL query for each recursion level and replace the names by adding a level number. I have done this for up to 6 levels without any problems.
Generally, DPL can be used to traverse tree structures. If you can´t find the problem I suggest that you construct an example here in this wiki so that I can have a look at it.
--Gero 16:19, 27 August 2009 (UTC)
- --Workdawg 17:21, 27 August 2009 (UTC) Well, that comment isn't there in the template itself, but I found the error anyway thanks to your comments. As you can see above, the 4th template calls the third, which in-turn, calls the 4th again... that wasn't intended. GetItemCost was the original name of GetRegularItemCost, but then I moved it to make way for the 4th template, since it made more sense to use a simple name for the template that would actually be used. Forgot to change the reference in there to point to where I moved it.
- The third should have looked like this.
{{#dpl:
|category = Components of {{{item}}}
|listseparators = ²{#expr:, + ²{#ifexist: Category:Components of %TITLE%{{!}}
²{CalculateRecipeItemCost{{!}}item=%TITLE%}²{{!}}
²{GetRegularItemCost{{!}}item=%TITLE%}²,}²,}²
}}
- Thanks for the help anyway :)
- How nice that you found the problem so fast!
- Maybe you can do something to promote DPL? Have a look at http://sesam.dyndns.info:60300/dewiki/index.php/DL_Chemikalien - this is the way I would like to see Wikipedia in future ..
- Even if you do not speak German you may get an idea of what I have in mind. It would be nice if you could drop some comments about DPL to attract some attention to it .. Thanks, Gero 18:39, 27 August 2009 (UTC)
- --Workdawg 19:01, 27 August 2009 (UTC) - When I was researching this extension, I noticed a "This wiki uses DPL" page someplace, and I was going to add a link to the wiki I'm working on, but I can't find that page again. If you can point it out, I'll add my wiki there.
- DPL:Websites_using_DPL , the link is at the very end of the homepage
Using DPL to suggest similar articles based on cats
Hi, we've been trying to use DPL to suggest articles with same categories as a sort of automated see also section (DPL in template code takes article categories and outputs articles which match them). It didn't seem possible to use current page categories as a DPL input so our developer created a mediawiki extension/magic word which does that but it would still require some changes to DPL to require at least two category matches for practical reasons. The trick is to make it work automatically without manually inputing the categories.
Recently I've discovered Extension:SeeAlsoSimilarArticles which is supposed to do more or less what we need but I couldn't make it work even on a clean mediawiki install and its development seems to be long halted. I understand it is based on original DPL so may be it is not entirely out of question to get similar functionality using DPL? Thank you for any clues.--Pethr 12:59, 19 January 2010 (UTC)
Response
I think it should be quite easy to do. Put the catlist of the current page into a variable and use that as an argument to a simple standard query.
- You need the "variables extension" and the string functions (both available via Download)
- we must use 'skipthispage=no'
- we must convert the comma separators to & because we want an AND-condition
- the whole thing should also work when moved to a template because the PAGENAME macro always delivers the article name and not the page of that template --> Template:Siblings , --> Somango
- one could try to avoid the intermediate variable (thus creating a real 'one-liner') but this would make the code more tricky and less readable.
- if it works for you: please leave a note and maybe you want to show the solution on the page where you found the non-working solution?
other pages which belong to the same category/ies as the current page:
{{#vardefine:cats|{{#replace:{{#dpl:title={{PAGENAME}}|skipthispage=no|addcategories=yes|format=,%CATNAMES%,}}|/, /|&}}}}{{#dpl:category={{#var:cats}}|addcategories=yes}}
--Gero 13:38, 19 January 2010 (UTC)
thanks for your suggest! the above code works well for one category, but if there are two categories in one article, it doesn't work. why?--Simonlisw 13:11, 25 May 2010 (UTC)
Example of 'goal'
I am attempting to move the goal keyword to level 3 functional richness.
When I use the parameter I get an error:
Extension:DynamicPageList (DPL), version 1.8.9 : WARNING: Unknown parameter 'goal' is ignored. Help: available parameters: ("goal" actually appears in the list of available parameters)
Can anyone explain why I'm having this problem?
My DPL code is:
<dpl> addcategories=true format=,\n* %CATLIST% goal=categories titlematch=%ma% notcategorymatch=English (English) mode=userformat </dpl>
- First, your dpl statement should look like this
<dpl> goal=categories titlematch=%ma% notcategorymatch=English (English) </dpl>
You could add "format=,\n* %TITLE%" if you do not want the categories to be displayed as hyperlinks. Note that %TITLE% refers to the CATEGORY name in the format statement!
Regarding the error message you got: you should make sure that functional richness has a value of 4. Look into you LocalSettings.php and add
ExtDynamicPageList::setFunctionalRichness(4);
Gero 12:22, 10 March 2010 (UTC)
I just installed DPLv2 (v1.8.9) on MW 1.15. If I set FunctionalRichness as follows in LocalSettings...
## DynamicPageList
include("$IP/extensions/DynamicPageList/DynamicPageList2.php");
ExtDynamicPageList::setFunctionalRichness(4);
...I get a fatal error. If I comment out the "ExtDynamicPageList::setFunctionalRichness(4);" line MW is fine. How do you properly call this set function?
calmo 15:30, 1 April 2010 (UTC)
error in showing a tag with DPL variables
Hi, it seems that DPL variables don't work in a tag.
The tag i use is from Extension:CommunityVoice :
{{#tag:ratings:scale||category=""|title=ABC}}
It's supposed to output :
<div id="cv_ratings_scale__ABC class="communityvoice-ratings-scale"> .....</div>
However, when using it with %TITLE% variable in DPL, %...% seems to cause a bug. The result becomes :
<div id="cv_ratings_scale__TITLE class="communityvoice-ratings-scale"> .....</div>
Using it with %PAGE%, it outputs:
<div id="cv_ratings_scale__PAGE" class="communityvoice-ratings-scale"> .....</div>
%...% isn't recognized here. do you know there's any method to deal with it? Thanks! --Dullmau 10:48, 28 June 2010 (UTC)
- Did you try to use the special characters that substitute certain wiki characters? Read the introductory part of the manual and look for ²{ ... }² and "broken pipe" symbol etc. Gero 21:29, 30 June 2010 (UTC)
- hi gero, sorry for replying late. I've forgotten where i posted the question and i suddenly found it back when i was reading the manual. Thanks, I'm trying your advice now. --Dullmau 11:38, 19 August 2010 (UTC)
help ...
Hi, I'd like to use DPL to show the latest added articles and each of them comes with an infobox with an image filename.With the code below, I can retrieve the filename now:
{{#dpl:
|addeditdate=true
|ordermethod=firstedit
|order=descending
|include={Infobox testing}:image // The parameter "image" is defined in each infobox. it's a filename such as "abc.jpg"
|count=10 // list the results
}}
The result is like this :
* 2010-09-03 15:26:24 testing image1.jpg * 2010-09-03 13:53:51 testing2 image2.jpg * 2010-09-03 13:53:51 testing3 image3.jpgbut how is it possible to put a on those retrieved filenames? DPL is very powerful but i'm very slow to learn how to use it.....please give me some hints. --Duma 08:49, 6 September 2010 (UTC)
- You need to use a surrogate template (aka phantom template). See ther manual. In that template you can use the file name to generate wiki syntax to display a thumb; a very brief example (WITHOUT phantom template, just to show how you can display an image):
- Hi, it really works now!!! I really appreciate your help so much! Thanks!! --Duma 11:43, 14 September 2010 (UTC)
how to display articles created before a particular day
Hi, I'm trying to display articles created before a particular day. It seems that the only similar option is lastrevisionbefore=201009210000 which will display articles "last revised" before 2010-9-21, 00:00.
I'm wondering if there's any simple method to do this? Anyway, i really like DPL and I finally got a dynamic main page. Thanks a lot! --Duma 12:46, 19 September 2010 (UTC)