Selectively hiding Help Center components using Curlybars Follow

Comments

13 comments

  • Avatar
    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.

  • Avatar
    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?

  • Avatar
    Ian Maison

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

  • Avatar
    Tess

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

  • Avatar
    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?

  • Avatar
    Tess

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

  • Avatar
    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!

  • Avatar
    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!

  • Avatar
    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!

  • Avatar
    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!

  • Avatar
    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!

  • Avatar
    Trapta

    Hi @Chris,

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

    Team Diziana

  • Avatar
    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}}

Please sign in to leave a comment.

Powered by Zendesk