From 9c19c8d95a9e6580a293a1a6fa26e2cf69fea553 Mon Sep 17 00:00:00 2001 From: ngoomie Date: Fri, 23 Aug 2024 23:34:32 -0600 Subject: [PATCH] Move subf/cat listing to its own template --- templates/index.html.ep | 31 +------------------------ templates/items/_list_subf_cat.html.ep | 32 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 templates/items/_list_subf_cat.html.ep diff --git a/templates/index.html.ep b/templates/index.html.ep index 01e03b3..ae06752 100644 --- a/templates/index.html.ep +++ b/templates/index.html.ep @@ -1,33 +1,4 @@ % layout 'default', % title => $c->board_name; -<% my $cat_header = begin %> - % my $_cat_id = shift; my $_name = shift; -
- <%= $_name %> -
-<% end %> - -<% my $subf_item = begin %> - % my $_subf_id = shift; my $_cat_id = shift; - % my $_name = shift; -
<%= $_name %>
-<% 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)) %> -<% }} %> \ No newline at end of file +%= include 'items/_list_subf_cat' \ No newline at end of file diff --git a/templates/items/_list_subf_cat.html.ep b/templates/items/_list_subf_cat.html.ep new file mode 100644 index 0000000..a4d9e30 --- /dev/null +++ b/templates/items/_list_subf_cat.html.ep @@ -0,0 +1,32 @@ +% # 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; +
+ <%= $_name %> +
+<% end %> + +<% my $subf_item = begin %> + % my $_subf_id = shift; my $_cat_id = shift; + % my $_name = shift; +
<%= $_name %>
+<% 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)) %> +<% }} %> \ No newline at end of file