How do I display sub-sections as blocks - just as sections are displayed in the homepage?
已回答
已于 2021年9月04日 发布
Hello everyone,
I'm trying to display my subsections as blocks, just as the sections are displayed on the Help Center homepage (see image below). I'm using the default Copenhaguen Theme and haven't made any modifications to it.
I'd appreciate anyone's help. Thanks in advance!
0
17
17 条评论
Peter Toprac
Hi,
Thanks for the code Ifra Saqlain
After adding this code into category_page.hbs, I can see sections as blocks, but they are also visible as links below the blocks.
How to exclude links below, and only have blocks displayed?
1
Matias Ricci Brochiero
Thank you both for your help! I appreciate it.
0
Greg Katechis
In addition to the incredibly helpful post by Ifra Saqlain (thank you!), I also wanted to mention that if you haven't made any modifications to your help center at all, the only reason that your sections would be showing on the home page is if you only had one category. Once you have more than one category that contains visible articles to the user, the categories will show on the home page instead.
0
Ifra Saqlain
@Matias Ricci Brochiero,
Have a look at the code:
1). Homepage suctions & subsections code.
Screenshot for the same:
Output would be: Sections & subsections are showing as a block on homepage.
2). Code snippet for section page.
Screenshot for the same:
Output would be :
When you add the subsection code on your HBS files, pay attention on the class-name.
<ul class="blocks-list">: blocks-list
<li class="blocks-item">: blocks-item
<a href="{{url}}" class="blocks-item-link">: blocks-item-link
<span class="blocks-item-title">{{name}}</span>: blocks-item-title
These are default classes which create the blocks for the section, subsection if you use sequently as I did above with <ul>, <li>, <a> & <span> tags.
You can use subsection code on category, section and homepage with the those classes to create the blocks on any template.
You only need to follow this structure with the same/default classes to get the subsection as a block.
If any confusion do let me know :)
Thanks
Team
1
Matias Ricci Brochiero
Hi Ifra & Greg - I appreciate your responses.
Greg - Community Manager, I've tried those, but when I add them to my code nothing happens. Everything seems to be the same.
Ifra Saqlain, maybe I wasn't clear enough. I want sections & subsections to be displayed as blocks not only on my homepage (sections there are already blocks by default) but also in the subsequent section pages.
Thanks again for your time. Looking forward to your help,
Matt
0
Ifra Saqlain
Hi @Matias Ricci Brochiero,
The given code snippet is for the subsections for the homepage, you can add the code anywhere on the home_page.hbs file. I'm using Copenhagen Theme.
Screenshot for the same:
Output is:
Thanks
Team
0
Greg Katechis
Hi Matias! The images that you shared are from this article and from what I can tell, the gist for subsections will do exactly what you're looking for. Just in case I'm misunderstanding, could you let me know what that code example is missing?
0
请先登录再写评论。