Difference between revisions of "Example 4"

From FollowTheScore
Jump to: navigation, search
(New page: In this example we do not use relations which were explicitly defined via template calls. Instead we use the normal hyperlinks. Thus we lose some semantics but we can apply this kind of ...)
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
In this example we do not use relations which were explicitly defined via template calls. Instead we use the normal hyperlinks.
+
With one line of code you can generate a menu tree which shows all links starting from a given article
 
+
<pre><nowiki>
Thus we lose some semantics but we can apply this kind of graph generation to any existing wiki contents!
+
{{#tree:{{Links 1|from|Wgraph}}}}
 
+
</nowiki></pre>
To make the graph prettier, we assign colors to the categories (Impressionism = magenta, Expressionism = yellow).
+
{{#tree:{{Links 1|from|Wgraph}}}}
We could also make shapes dependent from (other) categories ..
+
A depth of two levels is also possible:
 
+
<pre><nowiki>
Our example shows links from articles of category "Painter" to other articles of category "Painter".
+
{{#tree:{{Links 2|from|Wgraph}}}}
Note the bi-directional link between Renoir and Cezanne.<br>
+
</nowiki></pre>
A bigger example can be found '''[[Special:Call/Catgraph,uses2=CalendarSingle,layout=forcedir,userparm=repulsion:300|here]].'''
+
{{#tree:{{Links 2|from|Wgraph}}}}
 
 
In the SVG graph each node points to its wiki page.
 
 
 
First we show the output of the DPL query which is embedded in the ''Wgraph'' definition:
 
 
 
{|class=wikitable
 
!DPL result: The painters
 
!DPL result: Their relations
 
|-
 
|
 
{{#dpl:
 
  |category=Painter
 
    |addcategories=true
 
}}
 
|
 
{{#dpl:
 
  |category=Painter
 
  |mode=userformat
 
  |listseparators=,\n* [[%PAGE%]] -- [[%PAGESEL%]],,
 
  |linksto={{#dpl:
 
    |mode=userformat
 
    |category=Painter
 
    |listseparators=,%PAGE%¦,,
 
  }}
 
}}
 
|}
 
 
 
----
 
'''Below we see the graph and the WGL source which is generated by DPL;<br>
 
The nodetype statements were written by hand to make the result more pretty:'''
 
 
 
{{#wgraph: svg | thumb=40 | wgl |
 
 
 
  // the painters
 
  {{#dpl:
 
    |category=Painter
 
    |mode=userformat
 
    |addcategories=true
 
    |listseparators=,\n  node '%PAGE%' { type = '%CATNAMES%' },,
 
  }}
 
 
 
  // their relations
 
  {{#dpl:
 
    |category=Painter
 
    |mode=userformat
 
    |listseparators=,\n  edge from '%PAGE%' to '%PAGESEL%' {},,
 
    |linksto={{#dpl:
 
      |mode=userformat
 
      |category=Painter
 
      |listseparators=,%PAGE%¦,,
 
    }}
 
  }}
 
 
 
  // attribute settings for categories
 
  nodetype 'undefined node' { href '%%' }
 
  nodetype Impressionism { color lightmagenta href %% }
 
  nodetype Expressionism { color lightyellow href %% }
 
}}
 
 
 
continue with the '''[[Wgraph:Sample Genealogy|Genealogy Sample]]''' (series of 8 lessons on graph construction)
 
back to          [[Wgraph:Example 3]] ..
 
 
 
[[Category:Wgraph]]
 

Latest revision as of 06:35, 25 June 2009

With one line of code you can generate a menu tree which shows all links starting from a given article

 {{#tree:{{Links 1|from|Wgraph}}}}

{{#tree:


}} A depth of two levels is also possible:

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

{{#tree:


}}