Moved taxonomy html generation to CMS_TAXONOMY_API.

This commit is contained in:
2015-12-16 21:03:03 +01:00
parent 22528315cb
commit bbbdac12c8
2 changed files with 33 additions and 23 deletions

View File

@@ -334,30 +334,9 @@ feature -- Output
if if
a_response /= Void and then a_response /= Void and then
attached {CMS_TAXONOMY_API} cms_api.module_api ({CMS_TAXONOMY_MODULE}) as l_taxonomy_api and then attached {CMS_TAXONOMY_API} cms_api.module_api ({CMS_TAXONOMY_MODULE}) as l_taxonomy_api
attached l_taxonomy_api.vocabularies_for_type (content_type.name) as vocs and then not vocs.is_empty
then then
vocs.sort l_taxonomy_api.append_taxonomy_to_xhtml (a_node, a_response, a_output)
across
vocs as ic
loop
if
attached l_taxonomy_api.terms_of_content (a_node, ic.item) as l_terms and then
not l_terms.is_empty
then
a_output.append ("<ul class=%"taxonomy term-" + ic.item.id.out + "%">")
a_output.append (l_node_api.html_encoded (ic.item.name))
a_output.append (": ")
across
l_terms as t_ic
loop
a_output.append ("<li>")
a_response.append_link_to_html (t_ic.item.text, "taxonomy/term/" + t_ic.item.id.out, Void, a_output)
a_output.append ("</li>")
end
a_output.append ("</ul>%N")
end
end
end end
-- We don't show the summary on the detail page, since its just a short view of the full content. Otherwise we would write the same thing twice. -- We don't show the summary on the detail page, since its just a short view of the full content. Otherwise we would write the same thing twice.

View File

@@ -488,6 +488,37 @@ feature -- Web forms
end end
end end
append_taxonomy_to_xhtml (a_content: CMS_CONTENT; a_response: CMS_RESPONSE; a_output: STRING)
-- Append taxonomy related to `a_content' to xhtml string `a_output',
-- using `a_response' helper routines.
do
if
attached vocabularies_for_type (a_content.content_type) as vocs and then not vocs.is_empty
then
vocs.sort
across
vocs as ic
loop
if
attached terms_of_content (a_content, ic.item) as l_terms and then
not l_terms.is_empty
then
a_output.append ("<ul class=%"taxonomy term-" + ic.item.id.out + "%">")
a_output.append (cms_api.html_encoded (ic.item.name))
a_output.append (": ")
across
l_terms as t_ic
loop
a_output.append ("<li>")
a_response.append_link_to_html (t_ic.item.text, "taxonomy/term/" + t_ic.item.id.out, Void, a_output)
a_output.append ("</li>")
end
a_output.append ("</ul>%N")
end
end
end
end
feature -- Helpers feature -- Helpers
splitted_string (s: READABLE_STRING_32; sep: CHARACTER): LIST [READABLE_STRING_32] splitted_string (s: READABLE_STRING_32; sep: CHARACTER): LIST [READABLE_STRING_32]