% # this requires that you pass a category tree object to
% # any template that includes this component
<% my $cat_header = begin %>
% my $_cat_id = shift; my $_name = shift;
<% end %>
<% my $subf_item = begin %>
% my $_subf_id = shift; my $_cat_id = shift;
% my $_name = shift;
<% end %>
<%
foreach my $category ($category_tree->getAllChildren) { %>
<%= $cat_header->(
$category->getNodeValue,
$c->schema->resultset('Categories')->
title_from_id($category->getNodeValue)) %>
<%
foreach my $subforum ($category->getAllChildren) { %>
<%= $subf_item->(
$subforum->getNodeValue,
$category->getNodeValue,
$c->schema->resultset('Subforums')->
title_from_id($subforum->getNodeValue)) %>
<% }} %>