Chapter 93. Topics

The topic and article system is the most extensive and actively used feature of Midgard. Topic records form a hierarchical tree structure in which articles can be stored. Article records can for example represent normal articles or documents, parts of them, calendar entries, news items or organizational units.

The topic records form a tree hierarchy in the Midgard database. Each topic tree is started from a root topic whose up field is zero. The first level of the tree is formed by topis whose up fields point to the root topic, second level of topics with up fields pointing to records in the first level, and so on. One can traverse a tree branch from a given topic $topic to the root topic using the following code:


<ul>
<?php for ($t = mgd_get_topic($topic); $t; $t = mgd_get_topic($t->up)): ?>  
<li>&(t.name);</li>
<?php endfor; ?>
</ul>

The article records are the leaves of the topic tree. Each article record is linked to a topic by the topic field. There is no way to list all the articles in a database. Instead you can access the articles in a given topic or in the entire subtree starting from the topic.