最近搜索


没有最近搜索

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 条评论

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


请先登录再写评论。

找不到所需的内容?

新建帖子