Reusing content allows you to have a central location for a common set of text that can then be referenced on other articles throughout the site. If a change needs to be made, you can then modify the text in the central location allowing the rest of the text to be automatically updated.
MindTouch offers a programming language called DekiScript that can be leveraged to add programatic elements to your articles. We'll use the DekiScript function "wiki.page" which allows you to target a section of a page or the entire page to be included on a separate page, allowing you to update the content in a single location.
Create the Source Page
The easiest way to get started is to create a new page and title it. Then, add some content to the page which you'd like to reuse. You can compartmentalize the content with
You'll also want to copy the source page's path, you'll need it in the dialog.
Using the Content Reuse Dialog
- Now that you have your content page set up, go to a different page that you'd like to include the content to. Edit the page and you will see the Content Reuse button. When you click it the Content Reuse Dialog will display.
- Next you'll add the page path of the Content Page you would like to reuse from in the first column marked. If you'd like to copy the whole page and not a specific section you can leave it blank. You can start your page path with a backslash but it is not required. Then you'll click "Insert"
- After clicking insert you'll see a wiki.page call inside two curly brackets along with the page path you just entered.
- You can then save the page. You'll see that the contents of your source page are now displayed on our reuse page. As you update the content of your source page, your reuse page will automatically display the latest version of those contents when reloaded.
Reusing a Specific Section Only
- If you want to target a section and only pull in that Section, note that a section is a Header element within a MindTouch page and will include the contents of the section down to the next section level the Header element matches.
- After adding the section you would like to reuse you'll once again click the "Insert" button and you'll see the wiki.page call again with the section within parenthesis of the path wrapped in quotations with a comment separating itself from the path..
- After saving you'll see all of the page contents under the header you specified as a section. The header will not be added to the reused content. All header elements under that section's header element will be added, content reuse will stop at the bottom of the page or at the next equal or greater header element.
Extra additions to the Content Reuse call
- If you'd like to also display the section title in your reused page, you can use the following call:
wiki.page("/Page_Path", "Section Title",NULL, true, 1)
- For example:
- Will result in:
- In the above call you'll see additional parameters, true, and 1. When using additional parameters you'll need to add them in the order below:
wiki.page(path, section, revision, show, heading, nilIfMissing);
If you do not wish to use a specific parameter (e.g., we do not care about the revision parameter in our example) then you must put a "0" value in its place. All available parameters are covered below.
|path||str||wiki page path|
|section||str||(optional) section to include on wiki page (default: full page)|
|revision||num||(optional) page revision to use: 0 is the head revision, > 0 stands for a specific revision (e.g. 1 is the first revision), < 0 is revision relative to head revision (e.g. -1 is the previous revision) (default: head revision)|
|show||bool||(optional) show page/section title of included page (default: false) *requires heading parameter below to be explicitly set|
|heading||num||(optional) set page/section title heading and adjust all sub-headings accordingly; the adjustment is applied even when the page/section heading is not shown (range: 0-5, where 0 is 'Title' style, 1 is 'Heading 1', and so forth; default: keep original headings)|
|nilIfMissing||bool||(optional) return nil if page/section is not found (default: return link to missing page/section)|
It is possible to reuse a page which already contains a "wiki.page" call. In this scenario, whenever you load the new page you'll be making two (2) "wiki.page" calls. Depending on the amount of content you're reusing and the amount of "wiki.page" calls you're ultimately calling on page load, keep in mind that reusing content which already contains a "wiki.page" call can result in slower performance when loading the new page. For best practices, we recommend you avoid including more than 2 depths of "wiki.page" calls.
When reusing content with the "wiki.page" DekiScript call, page content will be reused though styles will not be included.
The "show" parameter requires a value to be set in the "heading" parameter. If you're looking to display the title of the section within your wiki.page invocation, set a "header" parameter (i.e., 1), and the "show" parameter to "true".
MindTouch does not support the use of the wiki.page function that executes an infinite loop. In this scenario, the following would hold true:
- Page A is included in Page B
- Page B is included in Page A
This leads to what is called an infinite loop and MindTouch will try to cyclically load the pages until it times out. This means that both Page A and Page B will load significantly slower than expected and may not load at all. This situation is allowed by MindTouch intentionally and is not a bug.
Nested Infinite Loops
In some scenarios, you may have a nested loop that occurs over more than two pages. In those cases, the following would hold true:
- Page A is included in Page B
- Page B is included in Page C
- Page C is included in Page A
All the pages would perform very slowly and may possibly not load. This scenario is not supported and you would have to eliminate the infinite loop by removing one of the wiki.page calls. This situation is allowed by MindTouch intentionally and is not a bug.
Self Contained Infinite Loops
In this last scenario, you may have an individual page that has it's own infinite loop. In this scenario, you would have used wiki.page on Page A to include a section from Page A. Page A would perform very slowly and may not load at all. To resolve this issue, you would have to remove the wiki.page from Page A. This situation is allowed by MindTouch intentionally and is not a bug.