Glossary Letter paragraph only displays 5 terms
-----------------------------------------------
Key: MGNLSTK-692
URL: http://jira.magnolia-cms.com/browse/MGNLSTK-692
Project: Magnolia Standard Templating Kit
Issue Type: Bug
Components: paragraphs, templates
Affects Versions: 1.3.5
Reporter: Matt Dertinger
Assignee: Philipp Bärfuss
Attachments:
config.modules.standard-templating-kit.dialogs.paragraphs.features.stkGlossaryLetter.xml.patch,
glossaryLetter.ftl.patch
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:
{code:xml}
[...@glossarytermsperletter letter=actualLetter /]
{code}
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:
{code:xml}
[#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!te...@name}</a></li>
[/#if]
[/#list]
</ul>
[#if letter?children?size > maxTerms]
<p class="all"><a
href="${mgnl.createLink(letter)}">${i18n['glossary.seeAllTerms']}
'${lett...@name}'</a></p>
[/#if]
[/#macro]
{code}
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.
h2. 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}}.
h2. Approach 2
Modify the {{glossaryTermsPerLetter.ftl}} macro, set the default value for
{{maxTerms}} to {{10000000}}.
For instance:
{code:xml|title=glossaryTermsPerLetter.ftl}
[#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!te...@name}</a></li>
[/#if]
[/#list]
</ul>
[#if letter?children?size > maxTerms]
<p class="all"><a
href="${mgnl.createLink(letter)}">${i18n['glossary.seeAllTerms']}
'${lett...@name}'</a></p>
[/#if]
[/#macro]
{code}
h2. Approach 3
(i) *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.
{code:xml}
[[email protected] editLabel="${i18n['glossary.editLabel.paragraph']}"
moveLabel="" deleteLabel="" /]
{code}
## Add {{maxTerms=content.maxTermsPerLetter!10000000}} to the call to the
{{glossaryTermsPerLetter}} macro, like so:
{code:xml|Updated glossaryLetter.ftl paragraph}
[#-- 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}" -->
{code}
# 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
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------