Posted by ErichSteinboeck on 01 Apr 2008 10:58, last edited by James Kanjo on 09 May 2010 05:50
Tags: conditional if include part
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.
Other(!) HowTos posted by ErichSteinboeck
- Include Part Of A Page Only (Tricky Version)
- Create Sortable List of Pages
- Set Up an Infobox — Exclude Specific Attributes
- System Variables
- Include a Forum Thread
- Include Inline
- Module Attributes via URL
- Include With Defaults
- Iframe Link
- Nested Comments
- Feed/FrontForum/ListPages/live template — %%date%%
- Date: How Long Ago?
- Page Count
- ListPages: Automatic Header
- System Variables: Details
- Direct Links to Sub-Pages of System Pages
- Set Up An Infobox
- How Many Days Does Your Wiki Exist





