Difference between revisions of "Treeview extension"
(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...) |
(simple tree list example) |
||
Line 36: | Line 36: | ||
*B | *B | ||
}} | }} | ||
+ | |||
+ | == Generating a Simple List as a Tree with DPL == | ||
+ | The simplest example of using DPL with the tree-view would be for creating single level lists such as the titles in a given category. The tree view requires that there be only a single root and all the items in the list need to be at the second level and thus all be preceded by double asterisks. The following example makes a list of all the articles in [[:Category:Cities]]: | ||
+ | {| | ||
+ | |valign=top| | ||
+ | <pre> | ||
+ | {{#tree:openlevels=1| | ||
+ | *'''Cities''' | ||
+ | {{#dpl:category=Cities|mode=userformat|listseparators=,**,[[%PAGE%]]\n,}} | ||
+ | }} | ||
+ | </pre> | ||
+ | |valign=top| | ||
+ | {{#tree:openlevels=1| | ||
+ | *'''Cities''' | ||
+ | {{#dpl:category=Cities|mode=userformat|listseparators=,**,[[%PAGE%]]\n,}} | ||
+ | }} | ||
+ | |} | ||
== Generating Simple Tree Views with DPL == | == 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 | 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 direction of the links (outgoing="from" or incoming = "to") |
Revision as of 08:30, 1 September 2007
Contents
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
minus.gif
arrow-Closed.png
arrow-Open.png
Folder
Folder-Open
Document
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 a Simple List as a Tree with DPL
The simplest example of using DPL with the tree-view would be for creating single level lists such as the titles in a given category. The tree view requires that there be only a single root and all the items in the list need to be at the second level and thus all be preceded by double asterisks. The following example makes a list of all the articles in Category:Cities:
{{#tree:openlevels=1| *'''Cities''' {{#dpl:category=Cities|mode=userformat|listseparators=,**,[[%PAGE%]]\n,}} }} |
{{#tree:openlevels=1| }} |
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:
- Wgraph
}}
{{#tree:
- Wgraph
- Aa
- Add "minimum-number-of-revisions" like Criteria for page selection
- Links 1
- Main Page
- Add "minimum-number-of-revisions" like Criteria for page selection
- Extension DPL
- Included Template Name Matching
- Links 1
- Manual
- Modifiedby can return crap result
- Requests for new features
- Specific enhancements for 'table from template' DPL
- StringFunctions extension
- StripMarkup extension
- Subfader
- Test linksfrom 2
- TourBusStop
- NavTree
- Old Homepage
- Schwallex
- TourBusStop
}}
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.