Selectively hiding Help Center components using Curlybars

Have more questions? Submit a request

25 Comments

  • Ian Maison

    Jake this is great and much appreciated.

    One option that is missing from this is that of hiding an article from the /hc/en-us/categories section. How would this be achieved in terms of an example?

    Thanks.

    0
  • Jake Bantz

    Hi Ian,

    I can provide a quick example in the default Copenhagen theme. To hide an article, the isnt has to go within the article iterator like this:

    That will hide my article 204156349 on the category page, but show all others. Does that help?

    0
  • Ian Maison

    Jake, you are an absolute legend. Well done, it worked and thank you so much.

    0
  • Tess

    This code works for hiding a category.  How do we hide a section?

    0
  • Jake Bantz

    @Ian glad that worked!!

    @Tess do you mean hiding an article on the section page template or are you trying to completely hide a section somewhere?

    0
  • Tess

    Category has 5 sections and I want to hide 1 of them.

    0
  • Jake Bantz

    Hi Tess,

    This is a similar idea to the other solutions, we just need to put the condition around the block which renders each section within the appropriate #each statement. Here is the solution to hide section 200952599 in my account (note the closing isnt right before the else which dictates the behavior for an empty category):

    Hope this is useful for you!

    0
  • Jacob

    Hi Jake - 

    This has all been so helpful. Thanks! I have very little coding experience, but I've been able to follow along to make a few small changes. I'm wondering if you could help me find a way to ignore our article template for just one of our articles. Basically, I've redirected our 'Video Tutorials' category button on our homepage to lead straight to the first article in that category. Now, for a better user experience, I would like this Video Tutorial article page to ignore most of the formatting that comes with the rest of our templates. Mainly, I'd like to remove the side bar with other article suggestions so I can embed a larger video player in the center of the page, and eventually a scrolling menu of additional videos below.

    I understand that this is a large undertaking, but if you could guide me in the right direction to avoiding the template for a specific article, that'd be awesome! Thanks!

    0
  • Jake Bantz

    Hi Jacob!

    I'm glad you were able to use this!

    This is pretty achievable, especially if it's only for one article. We would use an #is condition to check if the currently viewed article is the one where you want the special behavior. Then below the 'else' we will have the fallback behavior for all other articles:

    {{#is article.id 223196988}}
    Here is where you would put the special code for your video player.
    {{else}}

    The 'fallback' or existing article code would stay here.

    {{/is}}

    If there is a certain part of the template you want to use for the special video article and the rest of your articles, you would just leave that outside of this conditional statement.

    Hope that helps!

    0
  • Jacob

    Thanks, Jake! It was the 'article.id' that was tripping me up. My next challenge is to figure out how to incorporate this 'slick' carousel code I found!

    0
  • Chris Stock

    Is there a way to the inverse of hiding multiple categories and only show multiple categories? Say I have 20 categories and I only want to display 3, I'd rather specify the three I want to display rather than add 17 isnt blocks for ones I don't want to display.

    Thanks!

    0
  • Trapta

    Hi @Chris,

    You can use {{#is}} instead of {{#isnt}} for the three categories you want to list.

    Team Diziana

    0
  • Chris Stock

    Thanks @Trapta. You can use {{#is}} but you have to replicate the block of html you want to display for each category.

    e.g.

    {{#is id 123}}
    <h1>{{name}}</h1>
    {{/#is}}
    {{#is id 456}}
    <h1>{{name}}</h1>
    {{/#is}}
    {{#is id 789}}
    <h1>{{name}}</h1>
    {{/#is}}

    I'd like to be able to do something like:

    {{#is id 123 or 456 or 789}}
    <h1>{{name}}</h1>
    {{/#is}}
    0
  • Michelle Kinsey Bruns

    Hi there,

    Is there a way I can write logic into footer.hbs to selectively hide content only if the user is viewing the new request form? I have a global link to submit a new request that I'd like to hide if that's what the user is already in the middle of doing. Thanks.

    0
  • Jake Bantz

    Hi Michelle,

    There isn't a way to implement a conditional statement to check the current page, but you could possibly add a Javascript snippet in a <script> block only on the new request template which hides the link you're presenting in the footer. It's not a perfect solution, but may help you accomplish the behavior which you seek.

    0
  • Ole Lindtveit

    Hi, 

    I would like to hide meta data for articles - making sure author and edit date is hidden. I have succeeded in the article-view, but when articles are shown in search results, the meta data is shown. 

    Can you please help me in the right direction for hiding this info in search results as well? 

    Thank you!

    0
  • Vladan Jovic

    Hey Ole, all you need is to edit the search page template and remove these highlighted lines of the code:

    Let us know if this doesn't help! 

    0
  • Ole Lindtveit

    Sweet, it helped a lot! Thanks! 

    1
  • Jortgies

    Hi,

    I would like to display different sidebars on different category pages. On one category page there should a certain picture on the side and another picture for another category page. Is it possible to somehow check for the current page and then display the content accordingly?

    Thanks!

    0
  • Jake Bantz

    Hi!

    Could you maybe add alternate templates for these categories instead to render different sidebar experiences? We go into more detail on this in Adding multiple article, section, and category templates to your theme. This could remove some or all of the need to code the different behavior into a single template.

    1
  • Daniel

    Hi! 

     

    I am looking at only displaying the web widget on specific articles in my Help Center.

     

    How do i go about achieving this?

     

    Thanks!

    1
  • Jake H.

    Hi - we are preparing to use ZD Connect, and we'd like to restrict articles so that they only appear in Connect, but not in search or while browsing KB. Is that achievable with the curly bars? If so, how can we go about doing that? Thanks!

    0
  • Amy Gracer

    I'm looking to hide certain requests on the My requests page. I think I have found a way to do this based on subject and using the isnt helper, as below. All requests with the subject "hide me" will be hidden. 

    But as soon as I go live, this is going to impact all my users, so I want to make sure it's going to work as I expect. Does anyone have any experience with this use case?

    Has anyone hid a request based on a tag or label set on the ticket?

    Thanks!

    <tbody>
    {{#each requests}}
    {{#isnt subject "hide me"}}
    <tr {{#is status 'closed'}} class="request-closed" {{/is}}>
    <td class="request-info requests-table-info">
    <a href="{{url}}" class="striped-list-title" title="{{subject}}">
    {{#if subject}} {{subject}} {{else}} {{excerpt description characters=50}} {{/if}}
    </a>

    </td>
    </tr>{{/isnt}}
    {{/each}}

    </tbody>

    0
  • Amy Gracer

    I think I got this working. Our goal was to hide requests that were submitted by email, because we want customers to use the portal to submit, not email,

    We set a trigger to change Emailed requests to Type=Task

    Then I made sure that Type was an active field as Read Only for the end user. 

    On the My Requests and the Request page, I hid "Type" column and field, and then I used the tip above to hide all requests that were Type=Task. 

    Seems to be working. I'll share the code if anyone is interested. 

    0
  • Brett - Community Manager

    This is super helpful :)

    Thanks for sharing Amy!

    If you'd like, you can submit this as a separate Guide Community Tip as well and I will get it added to our monthly Community Roundup.

    Cheers!

    0

Please sign in to leave a comment.

Powered by Zendesk