-
Bug
-
Resolution: Fixed
-
Neutral
-
1.3.5
-
-
Yes
-
Empty show more show less
Hi,
I came across this issue while working with the Glossary templates. Currently, the Glossary Letter paragraph doesn't allow you to configure the number of terms to display. It includes the glossaryTermsPerLetter.ftl macro, then makes the following call:
[@glossaryTermsPerLetter letter=actualLetter /]
Since it doesn't set the maxTerms attribute, the @glossaryTermsPerLetter macro sets the maxTerms to 5
Here is the relevant code segment from the glossaryTermsPerLetter macro:
[#macro glossaryTermsPerLetter letter maxTerms=5] <ul> [#list letter?children as term] [#if term?node_type == "mgnl:content" && term_index < maxTerms] <li><a href="${mgnl.createLink(term)}">${term.title!term.@name}</a></li> [/#if] [/#list] </ul> [#if letter?children?size > maxTerms] <p class="all"><a href="${mgnl.createLink(letter)}">${i18n['glossary.seeAllTerms']} '${letter.@name}'</a></p> [/#if] [/#macro]
In addition, the stkGlossaryLetter template definition sets the defaultValue for maxTermsPerLetter to 6. However, this would only have an effect if the maxTerms attribute was set using this value.
There are a few approaches I can think of to resolve this issue, but I'm not entirely sure which one would be best.
Approach 1
Add maxTerms=content.maxTermsPerLetter!10000000 to the call to the glossaryTermsPerLetter macro in the glossaryLetter.ftl paragraph. Then update the Template Definition for stkGlossaryLetter, removing the mainArea/autoGeneratedParagraph/defaultValues content node that sets maxTermsPerLetter to 6.
Approach 2
Modify the glossaryTermsPerLetter.ftl macro, set the default value for maxTerms to 10000000.
For instance:
[#macro glossaryTermsPerLetter letter maxTerms=10000000] <ul> [#list letter?children as term] [#if term?node_type == "mgnl:content" && term_index < maxTerms] <li><a href="${mgnl.createLink(term)}">${term.title!term.@name}</a></li> [/#if] [/#list] </ul> [#if letter?children?size > maxTerms] <p class="all"><a href="${mgnl.createLink(letter)}">${i18n['glossary.seeAllTerms']} '${letter.@name}'</a></p> [/#if] [/#macro]
Approach 3
Note: I have attached patch files for the following approach.
- Modify the glossaryLetter.ftl paragraph
- Add an Edit bar that allows authors to set the maxTerms to display.
[@cms.editBar editLabel="${i18n['glossary.editLabel.paragraph']}" moveLabel="" deleteLabel="" /]
- Add maxTerms=content.maxTermsPerLetter!10000000 to the call to the glossaryTermsPerLetter macro, like so:
[#-- Rendering: Glossary all terms of its letter--] <div class="glossary-box glossary-details" id="letter-${actualLetter?lower_case}"> <h2>${actualLetter?upper_case}</h2> [@glossaryTermsPerLetter letter=actualLetter maxTerms=content.maxTermsPerLetter!10000000 /] </div><!-- end "glossary-box glossary-details" id="letter-${actualLetter}" -->
- Add an Edit bar that allows authors to set the maxTerms to display.
- Modify the stkGlossaryLetter Dialog Definition
- Add a maxTermsPerLetter content node to the stkGlossaryLetter Dialog Definition. @see config.modules.standard-templating-kit.dialogs.paragraphs.features.stkGlossaryLetter.xml.patch
Please let me know if you have any questions.
Thanks,
Matt
- is related to
-
MGNLSTK-715 Glossary: Glossary letter pages do not show all terms anymore
- Closed