Hiding categories from home page | Community
Skip to main content

Hiding categories from home page

  • February 21, 2016
  • 21 replies
  • 0 views

Hey guys...first post and only my second week using Zendesk...loving it so far! I have been searching all over, and tried the solutions I found so far..nothing working yet...

I am using a custom theme that has custom links at the top, that I am linking to 3 of my categories...underneath that are the usual boxes (i.e. Humble Squid style) that show my categories...I want to hide the 3 that I am custom linking to, from being shown automatically in these boxes...is that possible using JS or other code? 

The desk is support.trustylife.com...thanks!

This topic has been closed for replies.

21 replies

  • Author
  • February 21, 2016

also I'd like to remove some categories from the category tree underneath too...tried all the code solutions I've seen so far and they still remain!


  • Author
  • February 21, 2016

ok so i've managed to get both the categories I wanted hidden from both Category List and Category tree on the home page! however...2 issues...

1.  On the Category List...everytime I load the page, the hidden categories appear for a split second then disappear like they should...did I use wrong code or is the script in wrong place?

2. On the Category Tree...I got rid of the Category Titles/Sections that I needed to, but the grey line between the Titles/Sections are still there (you will see 5 grey lines below Announcements on my home page...how can I get rid of those?


ModeratorWes

@Dave -

1.  In order for the categories not to appear for a split second then you will need to hide these via CSS with a display: none.  Then your JQuery you will need to .show these.  

2.  What code did you use or did you get this resolved.


  • Author
  • February 22, 2016

Thanks so much for your help Wes! I've actually read a lot of your posts and studied your themes while setting up my help center...you've been a lot help already! 

1. could you explain a bit more? i.e. do i reference all categories in CSS?

2. I used: 

$('h2 a:contains("FAQs")').hide();
$('h2 a:contains("FAQs")').closest('.category').hide();  
 
$('h3 a:contains("Basics")').closest('.section').hide();  
$('h3 a:contains("Basic")').closest('.section').hide(); 
 
you should see on my help center I just added that code again...it makes the categories/sections disappear like i want them to, from the home page...but leaves those grey lines...plus when i go into the category (i.e. FAQs, the Sections are also gone from there, I think because i'm referencing them this way...)
 
thanks so much Wes!

ModeratorWes

@Dave - instead of using JQuery here, I would actually do the hiding of sections and categories via HTML on the Home Page.  I normally hide the categories by doing something like this:

{{#each categories}}
{{#is name 'General'}}

{{#is name 'FAQs'}}

{{else}}

....rest of the code goes here.

You can do the same for the sections.  If you use this code on your Homepage then the rest of the code will show just fine on the section page.

This may solve both your issues as if the categories would not flash for a second if you use the HTML like I referenced above.

 

 


  • Author
  • February 22, 2016

thanks so much Wes...I've tried the code you provided getting a syntax error...here is my code without your additions:

{{#if categories}}
<div class="knowledge-base">
<ul class="row category-list clearfix" id="category-list">
<li class="column column--sm-4 category-list-item">
<a class="category-list-item__link" href="{{url}}">
<h2 class="h5 category-list-item__title">{{name}}</h2>
</a>
</li>
</ul>
{{/section}}
<div class="category-tree" id="category-tree">
{{#each categories}}
<section class="category-tree-item">
{{#if ../has_multiple_categories}}
<h2 class="category-tree-item__title">
<a class="category-tree-item__title-link" href="{{url}}">{{name}}</a>
</h2>
{{/each}}

<div class="category-tree-item__sections row clearfix">
{{#each sections}}
<section class="column column--sm-6 column--md-4 section">
<h3 class="section__title">
{{#if internal}}
<span class="fa fa-lock" title="{{t 'internal'}}"></span>
{{/if}}
<a class="section__title-link" href="{{url}}">{{name}}</a>
</h3>
{{#if articles}}
<ul class="article-list">
{{#each articles}}
<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>
{{/each}}
</ul>
{{#if more_articles}}
<a href="{{url}}" class="btn btn--default see-all-articles">
{{t 'show_all_articles' count=article_count}}
</a>
{{/if}}
{{else}}
<p>
<i><a href="{{url}}">{{t 'empty'}}</a></i>
</p>
{{/if}}
</section>
{{else}}
<p>
<i><a href="{{url}}">{{t 'empty'}}</a> </i>
</p>
{{/each}}
</div>

{{#if more_sections}}
<p>
<a class="btn btn--default" href="{{url}}">{{t 'see_all_sections'}}</a>
</p>
{{/if}}
</section>
{{/each}}
</div>
</div>

can you see where I would need to change the each and is references? sorry for the noob questions! first time using zendesk...


ModeratorWes

I forgot you need to end your is statement so try this:

 

div class="category-tree" id="category-tree">

{{#each categories}}

{{#is name 'Announcements'}}

{{else}}
<section class="category-tree-item">
{{#if ../has_multiple_categories}}
<h2 class="category-tree-item__title">
<a class="category-tree-item__title-link" href="{{url}}">{{name}}</a>
</h2>

{{/is}}
{{/each}}


  • Author
  • February 22, 2016

tried that and still showing a syntax error on the {{/is}} ending statement...

Thanks so much for your help!


ModeratorWes

Can you remove the {{#if ../has_multiple_categories}} statement to see if thats throwing it off.


  • Author
  • February 22, 2016

this is what I have now, getting a syntax error at the ending {{/each}} statement near the end...I know I'm missing something simple but I can't see it...

<div class="category-tree" id="category-tree">

{{#each categories}}

{{#is name 'Announcements'}}

{{else}}
<section class="category-tree-item">
<h2 class="category-tree-item__title">
<a class="category-tree-item__title-link" href="{{url}}">{{name}}</a>
</h2>

{{/is}}
{{/each}}

<div class="category-tree-item__sections row clearfix">
{{#each sections}}
<section class="column column--sm-6 column--md-4 section">
<h3 class="section__title">
{{#if internal}}
<span class="fa fa-lock" title="{{t 'internal'}}"></span>
{{/if}}
<a class="section__title-link" href="{{url}}">{{name}}</a>
</h3>
{{#if articles}}
<ul class="article-list">
{{#each articles}}
<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>
{{/each}}
</ul>
{{#if more_articles}}
<a href="{{url}}" class="btn btn--default see-all-articles">
{{t 'show_all_articles' count=article_count}}
</a>
{{/if}}
{{else}}
<p>
<i><a href="{{url}}">{{t 'empty'}}</a></i>
</p>
{{/if}}
</section>
{{else}}
<p>
<i><a href="{{url}}">{{t 'empty'}}</a> </i>
</p>
{{/each}}
</div>

{{#if more_sections}}
<p>
<a class="btn btn--default" href="{{url}}">{{t 'see_all_sections'}}</a>
</p>
{{/if}}
</section>
{{/each}}
</div>
</div>
{{/if}}


ModeratorWes

Looks like I need to remote on this one.  I had another client that purchased the same theme that I had to add and edit some code.

https://join.me/486-335-710


ModeratorWes

@Dave - Just checking in to see how everything is going


  • Author
  • February 23, 2016

Wes! you are awesome, thanks so much for your help yesterday! REALLY appreciate it, just went over to your coffee link and sent a few coffee's your way :)...using the code you had setup I was able to make the final tweaks and finally everything is laid out how I had wanted! 

Still getting the flash where the hidden blocks load then disappear, do you think there is a css/js tweak for that?

Seriously thanks!


ModeratorWes

@Dave,

Glad to hear.  I just added some code that should fix the hidden blocks from displaying.  Also fixed your auto complete for your search bar so that will work now.  I have some code that will show the section names in front of your search results if you want that installed. 


  • Author
  • February 23, 2016

just reloaded and that worked perfectly, thanks! that sounds great with the section names! 


ModeratorWes

@Dave - code was added.  Best of luck with your product launch and hopefully I'll hear from you soon.  The price I quoted you was with the community, its cheaper without.


  • Author
  • February 23, 2016

awesome, thanks so much Wes, you've been so much help! hoping to add community in the near future, but just for my info could you send me a PM to my email for a without community theme?


ModeratorWes

Sure thing Dave, I will send you an un-official quote.  I can't send an official until I have all your requirements.


ModeratorWes

Estimate Sent.


  • March 17, 2016

Hi Guys, I'm trying this same approach using multiple {{#is}} helpers, but get a syntax error like Dave mentioned above. Were you able to find a solution that you could share? 

Thanks!

 


ModeratorWes

@Shane  - I don't really remember what I had to do as it was a pre-purchased theme so the code is very different.  I think I just use JQuery to show and hide the boxes.