DPL Example 015

From FollowTheScore
Jump to: navigation, search

Sometimes you want to show content from selected articles but you don´t want to show all of the contents. You may want to suppress images, certain parts of the text or you may want to ignore the category assignments which may be contsained in the transcluded text.

All this can easily be done with a #replace statement which manipulates the output of a tablerow.

The article on the United Republic of Tanzania contains in its last chapter several items:

  1. some regular text
  2. a category links
  3. two interwiki language links

If you include the whole chapter via

  {{#dpl:
   |titlematch=%Tanz%
   |include=#%-1
   |table=,,last chapter
  }}

You will see all of that content and the article which contains the DPL statement will become part of the categories mentioned in the article - which is in most cases not what you want:

Content page last chapter
United Republic of Tanzania

Some Text.de:Tansania xyz:Tanzania


So you should consider to add a statement like

  |tablerow=²{#replace:%%¦/\[\[Category:.*\]\]\s*/s¦¦}² 

or like

  |tablerow=²{#replace:%%¦/\[\[C?[a-z]+:.*\]\]\s*/¦}² 

to eliminate those portions of the text which you do not want to show.

Using the latter statement you will get the following output:

Content page last chapter
United Republic of Tanzania {{#replace:

Some Text.de:Tansania xyz:Tanzania|/\[\[C?[a-z]+:.*\]\]\s*/|}}