최근 검색


최근 검색 없음

Hiding the "related articles" box when there are no other articles in the section

답변함


2023년 3월 30일에 게시됨

Does anyone by chance know of code you can use to hide the "Related articles" box only when there aren't more articles in that section?

Here's an example of a page in our Help Center. 

We'd like the "Related articles" box to only appear when there are more articles in that section. Thank you!


0

1

댓글 1개

image avatar

Pulkit Pandey

Zendesk LuminaryCommunity Moderator

Hi Josh Hersh

Please add the below code at the bottom of your script.js file 

  var articleSidebar = document.querySelector(".sidebar-section-articles ul").childElementCount;
  if(articleSidebar <= 1) {
     document.querySelector(".sidebar-section-articles").classList.add("hidden");
  }

And also place the below CSS code at the bottom of your style.css file

.hidden {
display: none;
}

Let me know if it solves your issue

Thanks 

Pulkit

Team Diziana

0


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

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

새 게시물