Documentation
This function is called by the
RenderPlugin to implement the REST handler
for the hierarchy browsers.
Parameters
- web: name of the web where to extract the hierarchy from, defaults to BASEWEB
- root: top category inside the hierarchy to start extracting information from, defaults to TopCategory
- exclude: pattern of categories to be excluded from the tree
- depth: number of levels to extract, defaults to 2
- format: one of "browser", "sidebar", or "editor", defaults to "browser"
- open: categories to be expanded
- hidenull: hides empty categories
- nrleafs: list of
cat:count
items that specify the number of leafs per category; these values are used instead of computing them by HIERARCHY itself
- nrtopics: list of
cat:count
items that specify the number of topics per category; these values are used instead of computing them by HIERARCHY itself
Implementation
%STARTINCLUDE%[
%HIERARCHY{
web="%web{default="%BASEWEB%"}%"
top="%root{default="TopCategory"}%"
depth="%depth{default="2"}%"
exclude="%root{default="TopCategory"}%%IF{"defined exclude" then="|%exclude%"}%"
hidenull="%hidenull{default="off"}%"%IF{"defined nrleafs"
then="nrleafs=\"%nrleafs%\""
}%%IF{"defined nrtopics"
then="nrtopics=\"%nrtopics%\""
}%%IF{"defined search"
then="hideclosed=\"on\""
}% open="%root{default="TopCategory"}%%IF{"defined open"
then=", %open%"
}%%IF{"defined search"
then="$percntCATINFO{
web=\"%IF{"defined web" then="%web%" else="%BASEWEB%"}%\"
include=\".*%search%.*\"
matchcase=\"off\"
matchattr=\"title\"
header=\", \"
format=\"$topic\"
separator=\", \"
}$percnt"
}%"
separator=",$n"
format="$indent{
$indent \"text\": \"%DBCALL{
"%WEB%.%TOPIC%"
section="%format{default="browser"}%"
depth="%depth{default="2"}%"
fieldname="%fieldname%"
}%\",
$indent \"expanded\": $isexpanded,
$indent \"hasChildren\": $subcats,
$indent \"id\": \"$name\",
$indent \"children\": [$children]
$indent}"
}%
]%STOPINCLUDE%
%STARTSECTION{"browser"}%<a href='$url' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' />$percntENCODE{\"$title\" type=\"quote\"}$percnt</a>$percntIF{
\"'$cyclic' = '1'\"
then=\" <span class='foswikiAlert'>C</span>\"}$percnt$percntIF{
\"'$count' != '0'\"
then=\" ($count)\"
}$percnt%ENDSECTION{"browser"}%
%STARTSECTION{"plain"}%<a href='$url' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt'><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>%ENDSECTION{"plain"}%
%STARTSECTION{"sidebar"}%<a class='clsCategoryLink' style='background-image:url($icon);' href='$url' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt'><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>%ENDSECTION{"sidebar"}%
%STARTSECTION{"editor"}%<a href='#' class='$name clsCategory {depth:$depth}' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt' value='$name'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>%ENDSECTION{"editor"}%
%STARTSECTION{"leafselect"}%$percntIF{\"$leafs>0 and $depth <= %depth%\"
then=\"<img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink>\"
else=\"<a href='#' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt' value='$name' class='$name clsCategory {depth:$depth}'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>\"
}%%ENDSECTION{"leafselect"}%
%STARTSECTION{"solrfacet"}%<a href='#' class='$name clsCategory solrFacetValue {depth:$depth}' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt' value='category:$name'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a> $percntIF{\"$count>0\" then=\"($count)\"}$percnt%ENDSECTION{"solrfacet"}%
%STARTSECTION{"solrfacet_nocounts"}%<a href='#' class='$name clsCategory solrFacetValue {depth:$depth}' title='$percntENCODE{\"$summary\" type=\"entity\"}$percnt' value='category:$name'><img src='$icon' alt='$percntENCODE{\"$title\" type=\"entity\"}$percnt' /><noautolink>$percntENCODE{\"$title\" type=\"quote\"}$percnt</noautolink></a>%ENDSECTION{"solrfacet_nocounts"}%
Test
Plain
run test1
%STARTSECTION{"test1"}%
%DBCALL{"%TOPIC%" format="plain"}%
%ENDSECTION{"test1"}%
Browser
run test2
%STARTSECTION{"test2"}%
%DBCALL{"%TOPIC%" format="browser"}%
%ENDSECTION{"test2"}%
Editor
run test3
%STARTSECTION{"test3"}%
%DBCALL{"%TOPIC%" format="editor" exclude="TestCategory5"}%
%ENDSECTION{"test3"}%
Leaf select
[
{
"text": "' alt='TestCategory12' />TestCategory12",
"expanded": false,
"hasChildren": 0,
"id": "TestCategory12",
"children": []
},
{
"text": "' alt='TestCategory4' />TestCategory4",
"expanded": false,
"hasChildren": 0,
"id": "TestCategory4",
"children": []
}
]
Solr facet
[
]