Treeview extension

From FollowTheScore
Revision as of 13:00, 15 August 2007 by Gero (talk | contribs) (New page: == This demonstrates the use of the Treeview extension == Treeview can produce clickable tree lists. The interesting thing is that the input for Treeview can eit...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This demonstrates the use of the Treeview extension

Treeview can produce clickable tree lists. The interesting thing is that the input for Treeview can either be defined statically or can be derived from a DPL query.


The following images are used in Treeview:   plus plus   minus.gif minus   arrow-Closed.png arrow-Closed   arrow-Open.png arrow-Open   Folder Folder   Folder-Open FolderOpen   Document Doc   Spacer (Spacer)

Example (static definition of items)

Treeview recognizes lines which start with one or more asterisks just like the mediawiki parser does when it is looking for bullet point lists:

{{#tree:
*A
**A1
**A2
***A21
***A22
**A3
*B
}}

As a result you will get a clickable tree: {{#tree:

  • A
    • A1
    • A2
      • A21
      • A22
    • A3
  • B

}}

Generating Simple Tree Views with DPL

Treeviews can be generated by DPL, as in the following example. We define a Template called Template:Links 1 which expects

  • the direction of the links (outgoing="from" or incoming = "to")
  • the source page
  • an optional name for the source page

Now we can write something like:

 {{#tree:{{Links 1|from|Wgraph}}}}
               or
 {{#tree:{{Links 1|to|Wgraph|references to the ''Wgraph homepage''}}}}

which will give us two menu trees, one for each direction: {{#tree:


}}


{{#tree:


}}

Generating Advanced Tree Views with DPL

Using nested DPL statements we can even produce a menu which shows more than one level of linkage references. Although this can be solved generally with a recursive template we prefer to have an explicitly named template for two levels.

 {{#tree:{{Links 2|from|Wgraph}}}}
           and
 {{#tree:{{Links 2|to|Wgraph}}}}

This will produce the following tree menus: {{#tree:


}}


{{#tree:


}}

Note that Template:Links 2 uses a special notation to represent double curly braces and a special pipe symbol to separate template arguments:

²{subQuery¦parameter¦..}²

This is needed because we must defer the evaluation of subQuery to a moment in time where the DPL result of the first (outer) query has already been calculated. This is necessary because we want to use %PAGE% and %TITLE% as part of the argument list for subQuery.

DPL has a built-in replacement mechanism which will convert the special characters ²{,}² and ¦ to their normal counterpart at the appropriate moment. This is a very powerful feature as is allows recursive calls between DPL statements. See the DPL:Manual - General Usage and Invocation Syntax.