Issues with list of subsections on Category page
Answered
Posted Apr 14, 2021
Hi,
I've been struggling as a CSS newbie, so it'd be great if I can get some pointers!
I'm using the Copenhagen theme and I have a 4-layered help page: a category page which shows a couple sections, and each section includes sub-sections, and each sub-section includes articles.
As you can see, that doesn't look right.
- All sub-sections are shown in the blue "box", even though (I think) the style.css file indicates only a max of 3 items should be shown.
.section .section-list-item:nth-child(3) ~ .section-list-item {
display: none;
}I've tried using the code I could find in the community (not exactly the one in the screenshot below, but the main problem is that I'm not able to access "section"), but I get this type of error:
- There's a lot of space in between the subsections. I tried tweaking the style.css and the category template with no luck... How do I get rid of these?
This is my category template for some context:
<nav class="sub-nav">
<div class="container">
{{breadcrumbs}} {{search submit=false}}
</div>
</nav>
<div class="container">
<div class="category-container">
<div class="category-content">
<header class="page-header">
<h1>{{category.name}}</h1>
{{#if category.description}}
<p class="page-header-description">{{category.description}}</p>
{{/if}}
</header>
<div class="section-tree">
{{#each sections}}
<section class="section">
<h2 class="section-tree-title">
<a href="{{url}}">{{name}}</a>
{{#if internal}}
<span class="icon-lock" title="{{t 'internal'}}"></span>
{{/if}}
</h2>
{{#if articles}}
<ul class="article-list">
{{#each articles}}
<li class="article-list-item">
<a href="{{url}}" class="article-list-link">{{title}}</a>
</li>
{{/each}}
</ul>
{{#is article_count 1}}
{{else}}
{{#is article_count 2}}
{{else}}
{{#is article_count 3}}
{{else}}
<a href="{{url}}" class="see-all-articles">
{{t 'show_all_articles' count=article_count}}
</a>
{{/is}}
{{/is}}
{{/is}}
{{/if}}
{{#if sections}}
<ul class="section-list">
{{#each sections}}
<section class="section">
<li class="section-list-item">
<a href="{{url}}">{{name}}</a>
{{#if internal}}
<span class="icon-lock" title="{{t 'internal'}}"></span>
{{/if}}
</li>
</section>
{{/each}}
</ul>
<a href="{{url}}" class="see-all-sections">
Show all sections
</a>
{{/if}}
</section>
{{else}}
<i class="category-empty">
<a href="{{category.url}}">{{t 'empty'}}</a>
</i>
{{/each}}
</div>
</div>
</div>
</div>
Thank you!
0
4
4 comments
M_S
I'm sorry for the late reply! Yes, the sub-sections, like "Sub-section 1," contain articles.
Thank you for the example! It's helpful. I'll try to mess around with the CSS and see if I have any luck :)
0
Alejandro Colon
Now that I am able to see the whole photo and based on your explanation. It looks like those large spaces are spaces for articles that may or may not exist. I know that some templates show the articles and some do not. In your case, based on the code it does look like the articles should be showing and if there are more than 3 then the "show all articles" link should also be visible. Neither of which do I see in your screenshot.
Do you have some articles in those sub-sections? At the very least "Sub-section 1".
If not, then add some articles to see if that makes a difference.
Here is an example of how to identify the CSS affecting the large space.
0
M_S
Thank you, 366249934668!
I'm not able to share the link, but here's a full screenshot of the category page:
I don't think I quite understand the dev tools/targets, but I'll look at the links you posted. Thank you!
0
Alejandro Colon
If I am following correctly, you have 2 issues:
For the second issue at least, you can use CSS to target the sections that are too large by using the developer tools to identify the appropriate elements to adjust. Once you are able to do that, you should be able to add CSS to the stylesheet to make it look as you would like. Most likely, you do not need to wrap the subsection in any specific HTML as that is done for you already.
Looks like you are already on the way with the following code:
Also, and I am not certain, but it looks like those large spaces are potentially spaces for articles that may or may not exist. I know that templates show the articles and some do not. In your case, based on the code it does look like the articles should be showing and if there are more than 3 then the "show all articles" link should also be visible. Neither of which do I see in your screenshot.
I am not exactly sure what you are trying to target using this code but I usually use a reference guide when trying to pinpoint a target using CSS. Something like:
What would make this a lot easier to help troubleshoot would be a link to your guide if you are able.
0
Post is closed for comments.