"Show All Articles" within a Subsection on Section Page
RespondidaWhen a section has 5 or more articles, the parent category page uses the following code to create a "Show all articles" button below the list of the top 5 articles.
{{#if more_articles}}
<a href="{{url}}" class="section-see-more-button show-button">
{{t 'show_all_articles' count=article_count}}
</a>
{{/if}}
This produces the following:
When a section has a subsection, and that subsection has more than 5 articles in it. The "See all # articles" link does not show, even when I add the code in. With the above listed code added to the section template, my sub-sections still do NOT show the "See all # articles" link when they should. Section page looks like this:
How can I replicate the behavior on the Category template on the Section template?
-
Is this the default Copenhagen theme? Or a custom Help Center theme?
Can I get a direct link to your public Help Center? Might be something missing in the code for your (sub)sections so I’ll check.
-
Hi Thomas. Thanks for replying.
This is a custom theme. Here's the current code we have on the sub-section page. Can you let me know what I can add to get the desired behavior?<section class="section contacthero">
<div class="contacthero-inner">
{{search submit=false instant=true class='search search-full' placeholder='Search for articles...'}}
</div>
</section>
<div class="container">
<nav class="sub-nav">
{{breadcrumbs}}
</nav><div class="article-container">
<section class="section-articles collapsible-sidebar">
<h3 class="collapsible-sidebar-title sidenav-title">Navigation</h3>
<div class="nav-tree" id="{{section.name}}{{section.id}}"></div>
</section>
<section class="section-content">
<header class="page-header">
<h1 style="color:#d52f6f">
{{section.name}}
{{#if section.internal}}
<span class="icon-lock" title="{{t 'internal'}}"></span>
{{/if}}
</h1>
{{subscribe}}
{{#if section.description}}
<p class="page-header-description">{{section.description}}</p>
{{/if}}
</header><div class="header-underline"></div>
<br>
{{#if section.articles}}
<ul class="article-list show-articles">
{{#each section.articles}}
<li class="article-list-item {{#if promoted}} article-promoted{{/if}}">
{{#if promoted}}
<span data-title="{{t 'promoted'}}" class="icon-star"></span>
{{/if}}
<a href="{{url}}" class="article-list-link">{{title}}</a>
</li>
{{/each}}
</ul>
{{else}}
{{/if}}
{{#if section.sections}}
<div class="section-tree">
{{#each section.sections}}
<section class="section">
<h3 class="section-tree-title" style="margin-bottom:15px!important;">
<a href="{{url}}">{{name}}</a>
</h3>
{{#if articles}}
<ul class="article-list">
{{#each articles}}
<li class="article-list-item{{#if promoted}} article-promoted{{/if}}">
{{#if promoted}}
<span data-title="{{t 'promoted'}}" class="icon-star"></span>
{{/if}}
<a href="{{url}}" class="article-list-link">{{title}}</a>
{{#if internal}}
<span class="icon-lock" title="{{t 'internal'}}"></span>
{{/if}}
</li>
{{/each}}
</ul>
{{#if more_articles}}
<a href="{{url}}" class="see-all-articles">
{{t 'show_all_articles' count=article_count}}
</a>
{{/if}}
{{/if}}
</section>
{{/each}}
</div>
{{/if}}
{{pagination}}
</section>
</div>
</div><div class="back-to-top-button"><a class="back-to-top-link"></a></div>
-
Hi Paul
I have made some changes on your given template code, Please replace the below code with your section_page.hbs file
<section class="section contacthero"><divclass="contacthero-inner">{{searchsubmit=falseinstant=trueclass='search search-full'placeholder='Search for articles...'}}</div></section><div class="container"><navclass="sub-nav">{{breadcrumbs}}
</nav>
<divclass="article-container"><sectionclass="section-articles collapsible-sidebar"><h3class="collapsible-sidebar-title sidenav-title">Navigation</h3><divclass="nav-tree"id="{{section.name}}{{section.id}}"></div></section>
<sectionclass="section-content"><headerclass="page-header"><h1style="color:#d52f6f">{{section.name}}{{#ifsection.internal}}<spanclass="icon-lock"title="{{t 'internal'}}"></span>{{/if}}
</h1>{{subscribe}}{{#ifsection.description}}<pclass="page-header-description">{{section.description}}</p>{{/if}}
</header>
<divclass="header-underline"></div><br>{{#ifsection.articles}}<ulclass="article-list show-articles">{{#eachsection.articles}}<liclass="article-list-item {{#ifpromoted}} article-promoted{{/if}}">{{#ifpromoted}}<spandata-title="{{t 'promoted'}}"class="icon-star"></span>{{/if}}<ahref="{{url}}"class="article-list-link">{{title}}</a></li>{{/each}}</ul>{{else}}
{{/if}}{{#ifsection.sections}}<divclass="section-tree">{{#eachsection.sections}}<sectionclass="section"><h3class="section-tree-title"style="margin-bottom:15px!important;"><ahref="{{url}}">{{name}}</a></h3>{{#ifarticles}}<ulclass="article-list">{{#eacharticles}}<liclass="article-list-item{{#ifpromoted}} article-promoted{{/if}}">{{#ifpromoted}}<spandata-title="{{t 'promoted'}}"class="icon-star"></span>{{/if}}<ahref="{{url}}"class="article-list-link">{{title}}</a>{{#ifinternal}}<spanclass="icon-lock"title="{{t 'internal'}}"></span>{{/if}}</li>
{{#is@index >=5}}{{#ifmore_articles}}<ahref="{{url}}"class="see-all-articles">{{t'show_all_articles'count=article_count}}</a>{{/if}}{{/is}}
{{/each}}</ul>
{{/if}}</section>{{/each}}</div>
{{/if}}
{{pagination}}</section></div></div>
<div class="back-to-top-button"><a class="back-to-top-link"></a></div>Thank YouPulkitTeam Diziana -
Hi Pulkit,
Unfortunately, that did not work. ZenDesk rejected the "{{#is@index >=5}}" statement.
But, I was able to find an unelegant solution, which brought to light the reason this doesn't work in the first place. The section template is unable to parse the code within the "see all articles link" ({{t'show_all_articles'count=article_count}}), so I just replaced that with plain text "See all articles".
The bad part of this solution is that it shows "see all articles even when a section has <5 articles.If you can find a way to get the {{#is@index >=5}} readable by the ZD section template, let me know. -
Hi Paul,
I found the way please use the following to get the @index readable by ZD
{{#is@index5}}{{#if more_articles}}<ahref="{{url}}"class="see-all-articles">{{t'show_all_articles'count=article_count}}</a>{{/if}}{{/is}}Thank YouPulkitTeam Diziana -
Does anyone know if the limit of 5 articles is a bug or by design?
I can't find any documentation on this specific use case. -
Hi Matthias Brodelet
Its by design not a bug
Thanks
PulkitTeam Diziana
Por favor, entrar para comentar.
7 Comentários