Recherches récentes


Pas de recherche récente

How to include subsections in custom section template

Avec réponse


Publication le 07 mars 2023

Our help center is organized into a few layers of subsections. We're trying to create a custom section template that loops over the sections and then also loops over subsections to list out the articles within.

We created a new section template and applied that to the section that we're attempting to do this with.

Inside the template itself, we've got the following:

{{#if section.sections}}
{{#each section.sections}}
  <div>
    <h2>{{name}}</h2>
    <div>
      {{#if sections }}
{{#each sections}}
<div>{{name}}</div>
{{/each}}
{{/if}}
</div>
</div>
{{/each}}
{{/if}}

The idea is that we loop over each of the sections and the sections within each of those to simply render the name, but the editor is throwing the following error:


According to the documentation, section objects should contain an array of sections, so from that understanding, you should be able to loop over nested subsections as many times as you want:

https://developer.zendesk.com/documentation/help_center/help-center-templates/objects/#section-object

Either the syntax is wrong or that's not possible, though, so does anyone have any idea if we can actually render subsections within a template? 

I've also tried `section.sections` in the second each loop as well.

I've seen this:

https://support.zendesk.com/hc/en-us/articles/4408883063066-Displaying-subsections-in-your-help-center#topic_j3b_vgs_jhb

But it doesn't seem exactly the same and it is also for a different theme. We're using Braden not Copenhagen.


0

1

1 commentaire

image avatar

Greg Katechis

Zendesk Developer Advocacy

Hi Tom! It's hard to say how a customized theme is laid out differently from our default Copenhagen theme, as that is created by a third-party. If I'm understanding this properly though, you're looking to go multiple subsection "layers" deep on one page and that may be the issue. Since the section object returns another section object, it only has visibility into the current parent section's subsection and itself. This means you wouldn't be able to access a...excuse the made up word...subsubsection. 
 
I hope that makes sense, but less us know if you have any other questions!

0


Vous devez vous connecter pour laisser un commentaire.

Vous ne trouvez pas ce que vous cherchez ?

Nouvelle publication