Uploaded image for project: 'Magnolia Standard Templating Kit (closed)'
  1. Magnolia Standard Templating Kit (closed)
  2. MGNLSTK-692

Glossary Letter paragraph only displays 5 terms

XMLWordPrintable

    • Yes

      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

        Acceptance criteria

              ochytil Ondrej Chytil
              mderting Matt Dertinger
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: