Selectively hiding Help Center components using Curlybars

Return to top

62 Comments

  • Bob Garber

    Can this be used to hide specific file types in attachments?

    We are publishing a lot of DITA image files into KB and they are mostly all .png files.

    These end up as a huge list at the bottom of an article, which we don't want to see or need.

    We just want to block .png's. All of the other attachments we post are PDF's, Word, Excel, type files.

    Thanks.

    BobbyG66

    0
  • Ifra Saqlain
    Community Moderator
    Zendesk Luminary
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Hi Bob Garber, you can check (with if condition) the file type using JS and then hide this (png files only)

     

    Thanks.

    0
  • Bob Garber

    Thanks Ifra,

    I wrote this code, but it is hiding all file types. Not sure if I have something in the wrong order, or if the code is wrong.

          <section class="article-info">
            <div class="article-content">
              <div class="article-body">{{article.body}}</div>

              <div class="article-attachments">
                <ul class="attachments">
                    {{#each attachments}}
                    <script>
                        var extension = fileString.substring(fileString.lastIndexOf('.') + 1);
                        if (extension == ".png"){
                        } else {
                            <li class="attachment-item">
                              <a href="{{url}}" target="_blank">{{name}}</a>
                              <div class="attachment-meta meta-group">
                                <span class="attachment-meta-item meta-data">{{size}}</span>
                                <a href="{{url}}" target="_blank" class="attachment-meta-item meta-data">Download</a>
                              </div>
                            </li>
                        }
                    </script>
                  {{/each}}
                </ul>
              </div>
            </div>
          </section>
    0
  • Ifra Saqlain
    Community Moderator
    Zendesk Luminary
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Hi  Bob Garber,

    Add the code at the bottom of your script.js file:

    $(document).ready(function () {
      var _x =  $(".article-attachments .attachment-item > a[href$='.png']").parent("li").hide();
    })

    Screenshot for the same:


     

    Make sure document_head.hbs file must have jQuery CDN:

    <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>


    Screenshot for the same:
    1
  • 立松貴央 TakaoTatematsu

    Vlad 

    Thank you for your advice the other day. https://support.zendesk.com/hc/en-us/articles/4408845769882/comments/4483557247642

    The way you taught me helped me achieve what I wanted to do!!

    0
  • Bob Garber

    Thanks Ifra!!!

    That code worked perfectly! I owe you a coffee!

    Bob

    0
  • Maximilian Kreisler

    Ifra Saqlain is it possible to hide certain elements of the page based on a URL parameter?

    We would like to hide the header (as well as other elements) when the support page is visited from the web view from an app.

    0
  • Ifra Saqlain
    Community Moderator
    Zendesk Luminary
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Hi Maximilian Kreisler, yes you can hide using JS or CSS.

    Add CSS at top of the homepage like below.  I add this code at home_page.hbs because I'm hiding it only for homepage not other pages.

    -

    0
  • Lumi
    Zendesk Luminary

    HI, is there a way to hide articles from Search Results and/or Section page by labels or content tags. Essentially, if an article has the content tag 'abcdef', don't show it in the Search results? Thanks in advance!

    0
  • Vlad
    Community Moderator
    The Wise One - 2022
     if an article has the content tag 'abcdef', don't show it in the Search results

    - as far as I know, this is not supported by ZD, so it's not doable. 

     
    0
  • Lisa Sedlak

    Jake Bantz

    We are going to do a Beta test of a product. We want to link to articles in our help center, but don't want those showing up in a list or category, however. we DO want the direct link the the article show up. 

    For example:
    Let's say we have an iOS app for our product and we need to Beta test it. We have links in the iOS app that lead to how to use the app, but since the app is not available for use yet, we want to hide the articles, but have those testing to be able to see the articles (without having a Zendesk account). 

    Is this possible? 

    0
  • Lila Kingsley

    Lisa Sedlak we did something similar in our public help center.  We hid specific articles  from displaying in Category, Section and Article sidebar navigation cribbing Jake's code from his article_hide_in_sidebar.txt attachment.  Basically as he says you follow the convention of adding the isn't helper after the #each helper for articles in conjunction with the article id i.e. {{#isnt id 1234}}

    • For category_page.hbs:  insert the isnt helper after {{#each articles}}
    • For section_page.hbs & article_page.hbs:  insert the isnt helper after {{#each section.articles}}

    For more than one article you add multiple {{isnt}} and close each with {{/isnt}}.  I wanted/preferred to use labels instead of individual article ids but wasn't able to get that working.  

    Here's what our category_page.hbs code snippet looked like as an example (I just added the stuff surrounded by comments.

    {{#each articles}}

    {{!-- Special logic to hide Articles in navigation via isnt helper--}}
    {{#isnt id 111111}}
    {{#isnt id 222222}}
    {{#isnt id 333333}}
    {{!-- --}}

    <li class="article-list-item {{#if promoted}}article-list-item--is-promoted{{/if}}" >
    {{#if promoted}}
    <span class="fa fa-star" title="{{t 'promoted'}}"></span>
    {{/if}}
    <a class="article-list-item__link" href="{{url}}">{{title}}</a>
    </li>

    {{!-- Special logic to hide Articles in navigation via isnt helper--}}
    {{/isnt}}
    {{/isnt}}
    {{/isnt}}
    {{!-- --}}

    {{/each}
    0
  • Jake Bantz
    Zendesk Product Manager

    Lisa Sedlak, Lila is right on with their suggestion.

    There is a limitation that using these workarounds, it is not possible to hide the article from search (this is discussed a little earlier in the comments on this article). A possible workaround would be to instead use a custom page for the 'hidden' documentation, and provide those Beta users with the destination of that page.

    Hope that helps.

    0
  • Ari

    I’m using Zenplates’ Ruby theme and want to selectively hide about 12 articles from a category page and some of its sections.

    I’m still trying to figure out where to put the {{isnt id… codes for the theme templates, but my question is whether I need to include any html elements between the opening and closing {{/isnt}} since the intention is that those list items do not render.

    0
  • Lila Kingsley

    Ari the isn't helpers surround the code block that lists articles.  So essentially it's saying list the articles which are not the article id specified in the helpers.  You shouldn't need additional html.

    As far as location, you put the isn't helpers after the each articles helper on the category, section and article templates (see my comment above for full code snippet I used):

    • For category_page.hbs:  insert the isnt helper after {{#each articles}}
    • For section_page.hbs & article_page.hbs:  insert the isnt helper after {{#each section.articles}}

    NOTE:  I hid articles in ALL categories/sections/articles which is a bit different than what you want to do...but I would think you could possibly use if/else + the isn't helpers for that.

    https://developer.zendesk.com/documentation/help_center/help-center-templates/introduction/#conditional-helpers

    0
  • Alyssa

    Is there a workaround to hide an article from search as well? Ifra Saqlain perhaps you've cracked this? 

    Please Zendesk, let us publish unlisted articles 🙏🏼

    0
  • Abhishek Tiwary

    Hello Zendesk support,

    Can I hide a specific article from all the sections?

    For example, I have articles with the title, "Oxygen Publishing Metadata - do not delete". 
    I need to hide this article from all the sections across all the categories.

    Regards, 

    Abhishek Tiwary

    1
  • Ifra Saqlain
    Community Moderator
    Zendesk Luminary
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Hi Abhishek Tiwary,

     

    Solution 1

    Check the article id on section page and category page using

     {{#isnt id 360038927131}}

    All code

    {{/isnt}}


    Note: 360038927131 it's my article ID.

    Category Page:

     

     

     

     

    Section Page:

     

     

     

    Solution 2

    Make your article set as draft in your help center.

     

     

     

    If any confusion feel free to ask.

    Thanks

     

     

    0
  • Abhishek Tiwary

    Thank you Ifra Saqlain,


    My help center has many articles with the same title. I was thinking if it was possible to hide all of them at once using the article title?

    Regards,

    Abhishek Tiwary

    0
  • Ifra Saqlain
    Community Moderator
    Zendesk Luminary
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Abhishek Karn,

    copy the given code and paste it at the bottom of your script.js file,

     let tag = document.getElementsByTagName('a');
       for (let i = 0; i < tag.length; i++) {
          let anchorTag = tag[i];
          let value = anchorTag.innerHTML.trim();
        if (value == 'Oxygen Publishing Metadata - do not delete.') {
             anchorTag.parentElement.style.display = 'none';
          }
       }


    Screenshot for same:


     

    Now, your article would be hidden from all pages if exists.

    Make sure article title is correct which I mentioned in the above code

    Oxygen Publishing Metadata - do not delete. 

     

    0
  • Abhishek Tiwary

    Thank you Ifra Saqlain,

    This was a great help.

    Regards,

    Abhishek Tiwary

    0
  • Niraj Makwana

    So I have used this article to hide sections and it works, but the problem I'm having is, that an an agent the section and articles also become hidden for me. How do I do it so that the normal users can not see the hidden sections but and an admins/agent I see can. I think the only option can be is making each articles set to "Visible to Agents". but there are so many I'd have to set up in that way, any ideas?

     

    0
  • Christopher Kennedy
    Zendesk Developer Advocacy
    Hi Niraj,
     
    To make articles visible to agents only, the simplest approach would be to change the article permissions as you suspected.  This is also possible to do in a bulk update.
    0
  • Paolo Votta

    Hi everyone,

    Is it possible to hide the community button in the header of the homepage?

    We are in a testing phase and we do not want our end-users to see it for the moment.

    If possible could anyone share a code example?

    Thank you in advance for any input.

     

    0
  • Christopher Stock
    Community Moderator
    Zendesk Luminary

    Hey Paolo Votta, the community button won't appear if you do not have the community activated on your help center. But you can see it when you're in development mode.

    You can also remove the code from the header.hbs file, you're looking for {{link 'community'}}

    1
  • Greg Katechis
    Zendesk Developer Advocacy
    Hi Paolo! No need for any custom code for this, you can just disable the community by following the directions here. As an admin, you'll still be able to see it and work on it, which willl give you the same benefit without having to worry about any theme customizations!
    0
  • Paolo Votta

    Hello and thank you for your help! The thing is that I need the community to be activated but only visible to internal agents in this moment. Later on I will try to extend it for a specific user segment. It would be a great improvement if you can restrict the visibility of the community by user segment, and NOT only posts visibility, but the entire community. For the moment I will remove the community button from the code as it was suggested.

    Thank you for taking the time to reply to my question!

    0
  • Abdelhameed Khaled

    If I have multiple forms how to get the URL of each one of them . I want to include each of them in different articles of categories because I will hide submit a request 

    0
  • Ifra Saqlain
    Community Moderator
    Zendesk Luminary
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Hi Abdelhameed Khaled,

    Open your submit a request page and select the first form from the dropdown.

    You will get the URL of that form in the searchbar, copy that, and use it wherever you want.

     

    Again select the second form from the dropdown copy URL and use that.

    If any issues feel free to ask :)

     

    Thanks

     

    0
  • Abdelhameed Khaled

    Hi Ifra Saqlain thanks 

    Ok there is an issue . when I paste the URL in an article for example it still offer the drop down menu . what I want is to only show the specific form which I provided the link for so that customer or viewer cannot choose another one how to do this . is it possible from the code?

      

    0

Please sign in to leave a comment.

Powered by Zendesk