Posted by ErichSteinboeck on 02 Apr 2008 22:55, last edited by RobElliott on 18 Jun 2010 11:44
Tags: conditional if include part
How To Include Only a Part of Another Page (Tricky Version)
This is a more sophisticated version of How To Include Only a Part of Another Page as it allows you to use a page
- both on its own (i. e. not included in another page), and
- be able to omit certain parts of it when it is included in another page.
Step by Step
Create your included (and/or standalone) page by adding the following “markers” at the beginning and at the end of each optional block of text (that you want to be able to either include or omit):
- begin marker: [!--{$partn}--]@@@@ (where n=1, 2, …)
- end marker: [!-- --]
That means: surround the first optional block of text with [!--{$part1}--]@@@@ and [!-- --], surround the second optional block of text with [!--{$part2}--]@@@@ and [!-- --], and so on.
Note:
1. Do not use any Wikidot comment ([!-- --]) within the source code of any of your optional blocks
2. The Wikidot syntax does not allow the begin marker in certain positions, like between the [[table]] and the following [[row]] tag, although it is acceptable to use it between an [[/row]] and a [[row]] tag.
On your including page, specify partn=@@ for each optional block that should be omitted, e. g.
[[include name-of-included-page part2=@@]]
[[include name-of-included-page part1=@@ | part2=@@]]]
[[include name-of-included-page]]
All blocks not specified in the [[include …]] will be included by default.
How it works
By specifying partn=@@ you are
- replacing the begin marker [!--{$partn}--]@@@@ with [!--@@--]@@@@.
- The pair of underlined @@ convert the closing part (--]) of the Wikidot comment into raw text, that isn't interpreted.
- As such it leaves the opening part of a Wikidot comment, commenting out any following block of text.
If you do not specifying partn=@@
- the begin marker [!--{$partn}--]@@ is ignored because the first part is a simple comment and second part (the four @'s) is the empty string converted to raw text, and
- the end marker [!-- --] is again just a comment.
Examples
Example Include Page
Some text that's always there.
[!--{$part1}--]@@@@
The first block of text that is optional.
[!-- --]
[!--{$part2}--]@@@@
Another optional block of text
[!-- --]
[[table]]
[[row]][[cell]]Name:[[/cell]][[cell]]Its name[[/cell]][[/row]]
[!--{$part3}--]@@@@
[[row]]
[[cell]]Option:[[/cell]]
[[cell]]an optional row in a table[[/cell]]
[[/row]]
[!-- --]
[[row]][[cell]]Player:[[/cell]][[cell]]Any[[/cell]][[/row]]
[[/table]]
Example Included Page
| What you type … | What you get … | ||||||
|
Some text that's always there. The first block of text that is optional. Another optional block of text
|
||||||
|
Some text that's always there. Another optional block of text
|
||||||
|
Some text that's always there. The first block of text that is optional.
|
||||||
|
Some text that's always there. The first block of text that is optional. Another optional block of text
|
||||||
|
Some text that's always there. Another optional block of text
|
Links
This is an extension of the ideas presented in Include Part of a Page Only
Backlinks
Author
ErichSteinboeck. Please visit his/her userPage.
Other(!) HowTos posted by ErichSteinboeck
- Include With Defaults
- Include a Forum Thread
- Iframe Link
- Include Inline
- Direct Links to Sub-Pages of System Pages
- System Variables
- Create Sortable List of Pages
- System Variables: Details
- Set Up an Infobox — Exclude Specific Attributes
- Date: How Long Ago?
- Module Attributes via URL
- Page Count
- Feed/FrontForum/ListPages/live template — %%date%%
- Set Up An Infobox
- Nested Comments
- ListPages: Automatic Header
- Include Part Of A Page Only
- How Many Days Does Your Wiki Exist





