How to include subsections in custom section template

답변함


2023년 3월 07일에 게시됨

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개

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


댓글을 남기려면 로그인하세요.

원하는 정보를 못 찾으셨나요?

새 게시물