How To Include Only a Part of Another Page
Create your included page with “[!-- {$partn}” and “[!-- --]” markers (where n=1, 2, …) at the beginning and end of each block that you want to be able to selectively include or not.
That means: surround the first block of text, that may or may not be included with “{$part1}” and “[!----]”, the second block of text with “{$part2}” and “[!----]”, and so on. For example:
[!-- {$part1} ++++ This is Part 1 Four lines # One # Two # Three # Four [!----] [!-- {$part2} ++++ This is Part 2 Four more lines * One * Two * Three * Four [!----]
Note that you may not use any Wikidot comment ([!-- … --]) within the source code of any of your optional blocks.
On your including page, if you want to have the first block included, use e. g.
[[include name-of-included-page |part1= --] ]]
Or, if you want to have the first block excluded and the second block included, use
[[include name-of-included-page |part2= --] ]]
How it works
By specifying “|partn=--]” you are replacing the “{$partn}” marker in the included page with a closing Wikidot comment ([!----]). So the closing marker closes the starting Wikidot comment on the page, and allows the remaining content in the section to be rendered.
If you don't specify the marker with a Wikidot comment, then the entire marker's section is interpreted as a Wikidot comment, and as such the section will be “commented out” and not rendered on the page.
Example
Show first block, hide second
[[include inc:part-of-a-page-only part1= --] ]] | This is Part 1Four lines
|
Show second block, hide first
[[include inc:part-of-a-page-only part2= --] ]] | This is Part 2Four more lines
|
Show both blocks
[[include inc:part-of-a-page-only part1= --] | part2= --] ]] | This is Part 1Four lines
This is Part 2Four more lines
|
Show no blocks
[[include inc:part-of-a-page-only ]] |
Links
A practical application of this concept can be found in Set Up An Infobox
Backlinks
Authors
ErichSteinboeck. Please visit his/her userPage.
James Kanjo. Please visit his/her userPage.