Recent searches


No recent searches

How do you hide a category from the homepage?

Answered


Posted Jun 23, 2016

Hi there,

I'm trying to hide a category from the homepage without it hiding the category everywhere else.

I've tried using:

  $('li:contains("General")').hide();

That line works but it also hides any search results in that category. Could you please show me how to do this through html? Thank you!


0

20

20 comments

Hi Andy,

Here is a small hack 

  • I am taking Wiry merchant as a  reference to solve this
  • Go to home page and under component <div class="category-tree">  pass an attribute id="{{id}}" as shown:
     <section class="category" id="{{id}}">

  • Save the changes.
  • Now get the ID of the category you want to hide on the home page. (You can get it from the URL)
  • Go to JS and add the line as shown :
     $('#200999725').hide();

  • Replace the id with your category id.
  • Save and publish the changes.

Hope this would work. 

Let us know if you find any problem.

Cheers,

Diziana

0


image avatar

Jennifer Rowe

Zendesk Documentation Team

Thanks for helping out (as usual!), Diziana!

0


image avatar

ModeratorWes

Most Engaged Member of All Time - 2021

You can also use the {{#isnt}} placeholder. I prefer to not use JQuery unless absolutely needed.  The code would look like this and will hide the category.


{{#each categories}}

{{#isnt name 'CATEGORY NAME HERE'}}

...........Rest of code........

{{/isn't}}

{{/each}}

0


image avatar

Jessie Schutz

Zendesk Customer Care

Y'all are the best. :)

0


Hi,

I'm real late to the party, but I'm having the same issue, trying to hide a number of categories from the homepage, but without success.

Tried both:

$('li:contains("X")').hide();
$("section.category").has("a[href$='/hc/en-us/categories/200187754-Example-Category']").hide();

And none seem to work.

 

I also tried what Diziana suggested, but my code does not seems like that at all. The categories are called to the <ul> and not the "category tree".

This is my homepage code:

<section class="home-wrapper category-list-section section-padding">
<div class="container">
<div class="row">
<div class="col-xs-12">
<ul class="hc-category-list text-center">
</ul>
</div>
</div>
</div>
</section>
<section class="wrapper-home section-padding">
<div class="container">
<div class="category-tree">
<h3 class="articles-title"><span>Popular Help Articles</span></h3>
<!-- Zendesk's articles Component display recently viewed articles -->
{{recent_articles}}
</div>
<div class="category-tree">
<h3 class="articles-title"><span class="promoted-head">Promoted Articles</span></h3>
<!-- Zendesk's articles Component display promoted articles -->
{{#if promoted_articles}}
<section class="promoted-articles">
<h3>{{t 'promoted_articles'}}</h3>
<ul>
{{#each promoted_articles}}
<li>
<a href="{{url}}">{{title}}</a>
</li>
{{/each}}
</ul>
</section>
{{/if}}
</div>
</div>
</section>

 

Thanks!!

0


image avatar

Nicole Saunders

Zendesk Community Manager

Hey Yotan - I see that Wes answered your question over in the Hiding a Category thread, so be sure to check that out. Welcome to the Zendesk Community!

0


Hi How can ensure that the category and all associated articles and sections doesn't show in the search once I have hidden it using JQuery?

0


image avatar

ModeratorWes

Most Engaged Member of All Time - 2021

@Benjamin - In order to remove the articles from the search then JQuery will not do the trick.  You will need to restrict the sections to "Agents & Managers" only if you do this for each section then the Category, Sections, and articles will not show to regular end users.  Only Agents & Managers will be able to see that Category on the homepage and everything under it.

You can only restrict "User Segments" at the Section Level.

Hope this helps.

0


Is there no way to make the articles not searchable without using the user segments as this isnt set up on my help center?

0


image avatar

Jessie Schutz

Zendesk Customer Care

Hi Benjamin!

User segments are really the only way that you can restrict access to content (and therefore what shows up in search results) in Help Center. Can you tell me more about why you want those articles to not be searchable?

0


Is it possible to hide all categories and sections without it effecting what would otherwise be found search results? If so, may I inquire as to how? In this context the hidden category and sections would be on the home and all other pages. Thank you.

0


image avatar

Jessie Schutz

Zendesk Customer Care

Hi Hal!

I imagine that it's possible using JavaScript, but we'll need to get some of our coding gurus into the mix to give some details on what the code would look like. Can you tell me more about your use case for this?

0


Hi Jessie –

I responded to an email with the following but do not see my reply on this thread. If this post is duplicative please accept my apologies and kindly delete one of them.

I’ve since started another thread that addresses my question. However, in answer to your question:

Here is a simplified way to consider my inquiry.
Suppose you have three articles, A1, A2 and A3 all belonging to the same category and section.
Suppose you have two users, U1 and U2.
U1 is entitled to see A1, A2 and A3.
U2 is only entitled to see A3.
Under Zendesk current supported functionality, I would need two otherwise identical sections; S1 and S2. This because only sections can contain a “user segment”.
Therefore, S1 needs to contain A1 and A2, and S2 would need to contain A3. Granted, I could duplicate A3 and also place it in S1, but this should be avoided for what should be obvious reasons.
However, if we eliminate the *user facing name* “S1” and S2” from the equation and instead just return whatever appropriate article is inside the section, we avoid having to duplicate A3 and avoid U1 from seeing duplicative sections S1 and S2.

Unfortunately, I later come to understand that user segments are treated as an AND condition. I was hopeful that the user segment could be an OR condition, or better yet, at the discretion of the author of a particular section.

 

0


image avatar

Jessie Schutz

Zendesk Customer Care

Hey Hal! Thanks for the clarification.

With regard to responding via email, the email notifications for Community activity come from a no-reply email, so unfortunately responding to those won't update the Community thread.

As far as organizing your content, with the current content organization functionality, restricting by Section is the only option. I'd recommend grouping your content up according to who is supposed to be able to see it, and then use corresponding user tags to create the appropriate user segments for each one.

0


Jessie -

Your welcome. We can consider the matter closed at this point, however, I would like to add the following.

  1. I'm rather certain that I've replied to emails from Zendesk that are thread related and the reply has automatically been posted on the board.
  2. Your suggestion of content organization is precisely what I'm doing. Trouble is, the user segments are treated as a a Boolean AND condition. Therefore, I need to replicate articles, which I'd prefer to avoid.

0


I'm wondering someone can help me with the following. I have a category hidden (id 111111111), but I'd like to hide another category, eg. (id 2222222). Thanks!

 

<ul class="custom-blocks row clearfix mc" id="custom-blocks">
    {{#each categories}}
          {{#is id 111111111}}
          {{else}}
        <li class="column column--xs-6 column--sm-3 custom-block">
            <a class="blocks-item-link" href="{{url}}">
                {{#is id 3333333}}
                    <img class="category-icon" src="{{asset 'image.png'}}"/>
                {{/is}}
                <h4 class="custom-block__title">{{name}}</h4>
            </a>
        </li>
          {{/is}}
    {{/each}}
</ul>

0


Hi Martin!

I would take a look at the helpers available to code your content. In a default Help Center, the Categories are displayed similar to the following (found in the Home Page template documentation): 

<div class="knowledge-base">
<ul>
{{#each categories}}
  <li class="category-name">
    <a href="{{url}}">{{name}}</a>
    <ul>
    {{#each sections}}
      <li class="section-name">
        <a href="{{url}}">{{name}}</a>
      </li>
    {{/each}}
    </ul>
  </li>
{{/each}}

{{pagination}}
</ul>

If you want different behavior for a specific Category, then you can use and is or isnt helper to specify how you'd like that content to display (or not display) instead.

I hope this helps!

 

 

0


Hello,

I passed an id attribute id="{{id}}" to obtain an specific ID for each Category Title. The token works great, but when I target the ID using CSS nothing happens. Could someone please help me to figure out what I am doing wrong?

Thanks!
 

 

0


image avatar

Vlad

The Wise One - 2022Community Moderator

Hi Yeny, try with  id="category-{{id}}" instead of  id="{{id}}"

0


Thank you for your prompt reply Vladan Jovic. It works now :)

0


Post is closed for comments.

Didn't find what you're looking for?

New post