[MGNLSTK-692] Glossary Letter paragraph only displays 5 terms Created: 26/Oct/10  Updated: 19/Jan/11  Resolved: 19/Jan/11

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: paragraphs, templates
Affects Version/s: 1.3.5
Fix Version/s: 1.3.6, 1.4.2

Type: Bug Priority: Neutral
Reporter: Matt Dertinger Assignee: Ondrej Chytil
Resolution: Fixed Votes: 0
Labels: stk, templates, templating, templating_kit
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File config.modules.standard-templating-kit.dialogs.paragraphs.features.stkGlossaryLetter.xml.patch     Text File glossaryLetter.ftl.patch    
Issue Links:
relation
is related to MGNLSTK-715 Glossary: Glossary letter pages do no... Closed
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Date of First Response:

 Description   

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:

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!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.

  1. Modify the glossaryLetter.ftl paragraph
    1. Add an Edit bar that allows authors to set the maxTerms to display.
      [@cms.editBar editLabel="${i18n['glossary.editLabel.paragraph']}" moveLabel="" deleteLabel="" /]
      
    2. 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}" -->
      
  2. Modify the stkGlossaryLetter Dialog Definition
    1. 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



 Comments   
Comment by Magnolia International [ 17/Dec/10 ]

Thanks for the patches, Matt; trying to push this into the upcoming 1.4.2 !

Comment by Ondrej Chytil [ 22/Dec/10 ]

Thanks for the patch Matt.

Comment by Ondrej Chytil [ 28/Dec/10 ]

Uncomplete paths in update task.

Comment by Philipp Bärfuss [ 19/Jan/11 ]

I think the updated task is wrong: it checks for the existence of a node which it is about to create.

note: please use a node builder which is definitely more readable. Using PartialBootstrapTask might be more appropriate.

Generated at Mon Feb 12 07:29:30 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.