This How-To explains how to use DekiScript to add a dynamic tree navigation to one of your articles. After completing this how-to you will understand what DekiScript is and how to add DekiScript to an article. Additionally you will understand how to embed a dynamic tree navigation with the ability to configure the beginning node for the tree navigation.
What is DekiScript
DekiScript is a scripting language in MindTouch that can be used to add dynamic functionality to your articles. Examples include conditions (IF statements), top 10 lists, directories and more. For more information on DekiScript please see the DekiScript Guide.
Adding DekiScript to an Article
- Go to the article that you want to add DekiScript to.
- Make sure the editor is loaded. If it isn't click Edit page.
- Go to the bottom of the page.
- In the editor click the Insert menu.
- Select DekiScript.
- Once you have created the DekiScript block you will need to paste the following DekiScript:
The example above uses the wiki.tree() function as is, however, it can be customized further using the following parameters:
|path||str||(optional) wiki page path|
|depth||num||(optional) nesting depth for retrieving child pages (default: all)|
|reverse||bool||(optional) reverse order of child pages |
Customizing the Path
By default the wiki.tree() function will display a tree of content that originates from the home page. If you wish to alter the origin you can enter in a path to use instead of the homepage. The Path is the part of the URL that is after the domain. For instance, if your page was http://help.mindtouch.us/MindTouch_T...eveloper_Guide then your path would be /MindTouch_TCS/Developer_Guide. To specify a path you can use the following DekiScript:
The following DekiScript also accomplishes the same thing:
Customizing the Depth
By default the wiki.tree() function will display all articles under the source path. In some cases this can be very time consuming and may drastically deplete the performance of the page. By modifying the depth parameter you can change the scope of the tree to only include a limited number of layers.
For instance, if your hierarchy has 15 layers, but you only wanted to display the top two, you can set the depth to two. Use the following DekiScript to modify the depth:
The following DekiScript accomplishes the same result as described above, however, it doesn't require that you enter a path:
Tip: Because the depth parameter is a number you do not need to wrap it in quotes.
- Add a version indicator to your documentation (MT4)
- Apply conditional global variables (MT4)
- Build a widget to display file attachments (MT4)
- Create conditional content on a page (MT4)
- Embed a tree navigation using DekiScript (wiki.tree) (MT4)
- Exclude pages from the popular pages list (MT4)
- Add a table of contents (MT4)
- Reuse content on your site (MT4)
- Set up global variables (MT4)
- Show a list of recently modified articles with a specific tag (MT4)
- Use foreach in DekiScript (MT4)
- Use if/else statements in DekiScript (MT4)