Test includetrim

From FollowTheScore
Revision as of 05:38, 7 April 2008 by EmuWikiAdmin1 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Test includetrim

Or Why is it always good to use includetrim=true when you want to include chapter content with mode=userformat ?

includetrim=true is an argument that you can add to your DPL invocations so that DPL removes ¶ characters at the beginning and at the end of a chapter when you include chapter content in a DPL invocation. The purpose of this is to avoid that the ¶ characters that are always present in all mediawiki's chapters come and break the structure that you want for your DPL invocation. Basically, it allows you to include chapter content without including the ¶s, which gives you more freedom if you want to make some fancy table structures or any other list. By the way I use an example of mode=userformat but the use of includetrim is not limited to mode=userformat.


We create pages that contain chapter contents :

Random Chapter Content 1

Random Chapter Content 2

Random Chapter Content 3


Now we want to create tables that will display the chapter content from some sections (chapters) of these pages. Using the mode userformat we want to have full freedom on the output of DPL. When using mode=userformat and including chapter content, it is good to also switch includetrim=true. Here is where includetrim=true is put :

<DPL>
category            =Random Chapter Content
mode                =userformat
nottitlematch       =Random Chapter Content
includepage         =#Random,#Chapter,#Content
addfirstcategorydate=true
listseparators      =,,,
secseparators       ={| border="0" style="background:black; color:white" cellspacing="0" border-collapse="collapse" bordercolor="black"¶|- style="background:black; color:white"¶!width="425"|[[%PAGE%|,]],¶!width="300"|,¶!width="200"|%DATE%¶|- align="center"¶|,,|| Some text here.¶|}¶
includetrim         =true
</DPL>

This piece of code has the includetrim=true switch, and it produces this :

This is a random sentence. 1. This is a chapter. 1. 2008-04-07 04:03:20
This is some content. 1. Some text here.
This is a random sentence. 2. This is a chapter. 2. 2008-04-07 04:04:08
This is some content. 2. Some text here.
This is a random sentence. 3. This is a chapter. 3. 2008-04-07 04:04:50
This is some content. 3. Some text here.


Now what would have happened if we did not use includetrim=true ? Here it is :

This is a random sentence. 1.

This is a chapter. 1.

2008-04-07 04:03:20

This is some content. 1.|| Some text here.

This is a random sentence. 2.

This is a chapter. 2.

2008-04-07 04:04:08

This is some content. 2.|| Some text here.

This is a random sentence. 3.

This is a chapter. 3.

2008-04-07 04:04:50

This is some content. 3.|| Some text here.


Why does it do that ? A good thing with DPL is that we have the debug = 5 argument that we can add. This argument allows us to actually SEE what's happening inside DPL's head. Actually, it allows DPL to display its final output. Here is the output of DPL with the includetrim=true argument and debug=5 argument :

{{Extension DPL}}{| border="0" style="background:black; color:white" cellspacing="0" border-collapse="collapse" bordercolor="black"
|- style="background:black; color:white"
!width="425"|[[Random Chapter Content 1|This is a random sentence. 1.]]
!width="300"|This is a chapter. 1.
!width="200"|2008-04-07 04:03:20
|- align="center"
|This is some content. 1.|| Some text here.
|}
{| border="0" style="background:black; color:white" cellspacing="0" border-collapse="collapse" bordercolor="black"
|- style="background:black; color:white"
!width="425"|[[Random Chapter Content 2|This is a random sentence. 2.]]
!width="300"|This is a chapter. 2.
!width="200"|2008-04-07 04:04:08
|- align="center"
|This is some content. 2.|| Some text here.
|}
{| border="0" style="background:black; color:white" cellspacing="0" border-collapse="collapse" bordercolor="black"
|- style="background:black; color:white"
!width="425"|[[Random Chapter Content 3|This is a random sentence. 3.]]
!width="300"|This is a chapter. 3.
!width="200"|2008-04-07 04:04:50
|- align="center"
|This is some content. 3.|| Some text here.
|}

That's what we wanted to have a nice looking table. Now let's see what DPL is outputting WITHOUT includetrim=true :

{{Extension DPL}}{| border="0" style="background:black; color:white" cellspacing="0" border-collapse="collapse" bordercolor="black"
|- style="background:black; color:white"
!width="425"|[[Random Chapter Content 1|
This is a random sentence. 1.]]
!width="300"|
This is a chapter. 1.
!width="200"|2008-04-07 04:03:20
|- align="center"
|
This is some content. 1.|| Some text here.
|}
{| border="0" style="background:black; color:white" cellspacing="0" border-collapse="collapse" bordercolor="black"
|- style="background:black; color:white"
!width="425"|[[Random Chapter Content 2|
This is a random sentence. 2.]]
!width="300"|
This is a chapter. 2.
!width="200"|2008-04-07 04:04:08
|- align="center"
|
This is some content. 2.|| Some text here.
|}
{| border="0" style="background:black; color:white" cellspacing="0" border-collapse="collapse" bordercolor="black"
|- style="background:black; color:white"
!width="425"|[[Random Chapter Content 3|
This is a random sentence. 3.]]
!width="300"|
This is a chapter. 3.
!width="200"|2008-04-07 04:04:50
|- align="center"
|
This is some content. 3.|| Some text here.
|}

You can see that everywhere we've called chapter content, DPL preceded the display of chapter content by a line change (¶, return) (Look at every word This. Every This is preceded by a line change (¶, return)). This line changes are bugging our display; we don't want them we want the nice-looking table. We can't change Mediawiki : All chapters in Mediawiki start with a ¶. But we can change DPL.


By using the includetrim=true argument.



Feature by Gero, Test description by EmuWikiAdmin1