Show less than 6 articles on Category.hbs template

165 Comments

  • Tim Finney
    Comment actions Permalink

    @Wes

    That would explain the issue. I must have missed that detail, my apologies. I'm using Swiftest Elk. 

     

    Thanks,

    Tim

    0
  • Wes Drury
    Comment actions Permalink

    Be right back let me test with that theme and see if I run into any issues.

    0
  • Wes Drury
    Comment actions Permalink

    It worked correctly in the Swiftest Elk as well.  See screenshot below.

    Can you post a link to your Help Center so that I can see what you have on the backend.

    0
  • Tim Finney
    Comment actions Permalink

    Unfortunately it isn't public yet. Is your screenshot from your home page? I'm happy to provide specific code if that helps.

    From the home page, everything is good. It is once I click a category and then get directed to the category page that I have the issue.

     

    Thanks,

    Tim

    0
  • Wes Drury
    Comment actions Permalink

    @Tim,  Got it I was only looking at the home page.

    Give this code a try:

    if( document.location.href.indexOf('section') == -1 ) {
    var categories = $('ul.article-list');
    for (var j = categories.length - 1; j >= 0; j--) {
    var articles = $(categories[j]).find('li'),
    nativeMore = $(categories[j]).siblings('.see-all-articles');
    if ( articles.length > 3 ) {
    for (var k = 3; k < articles.length; k++ ) {
    $(articles[k]).hide();
    }
    var moreLink = $(categories[j]).parent().find('h3 a').attr('href'),
    linkText = '';
    if( articles.length <= 6 && nativeMore.length == 0 ) {
    linkText += "See all " + articles.length + " articles";
    }

    }
    }
    }

    0
  • Tim Finney
    Comment actions Permalink

    Thanks. That did solve the problem on the category page but now there are no links in any sections with less than 'see all 8 articles'. For example, the 'OMS Introduction' section actually has 6 articles but the link to see more has now disappeared.

     

    0
  • Tim Finney
    Comment actions Permalink

    The links for less than 8 articles have disappeared from the home page as well.

    0
  • Tim Finney
    Comment actions Permalink

    Hi Wes,

    I want to follow up here. Any chance you have a solution for this? 

    Thanks,

    Tim

    0
  • Jennifer Rowe
    Comment actions Permalink

    IceCommunityManager thanks so much for sharing your solution!

    Did Wes's solution not work for you because of your home page accordions?

    Would you be willing to post your whole solution/comment in a new post so that users can easily find it? You can make the title of the tip similar to this one, but maybe include something about accordions to differentiate it.

    If so, we can send you a t-shirt for the effort. :)

    Thanks!

    0
  • Jennifer Rowe
    Comment actions Permalink

    No worries. We'll look forward to seeing that tip when you get some time. I'm sure it will help someone out there. Our Help Center customization tips are very popular!

    Wes will be happy to know that you were able to repurpose his code. Glad he was able to help via Slack. And, yes, he is awesome and deserves a promotion, no doubt!

    I'm doing my best to keep Wes busy doing customizations for our Help Centers right now!

    0
  • Jennifer Rowe
    Comment actions Permalink

    Thanks for updating it Wes!

    0
  • Trapta
    Comment actions Permalink

    @Martijn-S

    You're right on the downside about jQuery technique. In fact, your solution is more precise than the one I mentioned. One should use your solution over mine.

    Thanks for sharing it :)

    0
  • Marta Ramos
    Comment actions Permalink

    Hi Wes, in my case I would like instead of showing "See X articles" i would like to show every single article i have tried using some code you left behind 

    //Trick zendesk into showing all articles
    $('ul.article-list li a').removeAttr('data-asynchtml-ressource');

     

    but it simply doesn't work can you help me? Thank You

    0
  • Marta Ramos
    Comment actions Permalink

    Hi Wes thank you for answering.

    No, i really don't want "see all 12 articles" to appear one example that I can give you is the helpdesk of slack. They use zendesk and in the category folders all articles are shown https://get.slack.help/hc/en-us/categories/200111606 and i wanted something like that. Thank you

    0
  • Trapta
    Comment actions Permalink

    Hi @Marta,

    In that case, you can use the {{section_tree_with_article}} component of Zendesk and tweak UI to make it look like a list or as per your needs.

    The one you have mentioned as an example is using the same technique but keep in mind that this component also has restrictions on 30 articles. It will not list more than 30 articles of a section.

    Thanks

    Team Diziana

    0
  • Marta Ramos
    Comment actions Permalink

    Hi @Trapta 

    thank you for your answer after some research i really can't understand where i'll use {{section_tree_with_article}}  can you please help me more. I haven't mentioned and I don't know if it matters or not but i am changing the Copenhagen theme. In my case i don't have any category with 30 articles so that should work just fine. Thank you so much for your feedback and i'll be waiting for you help thank you

    0
  • Trapta
    Comment actions Permalink

    @Marta,

    If you want to show the list on the homepage, then you can use {{category_tree_with_article}} helper. Its availability is on the homepage only.

    If you want to show the list on category template, then you can use {{section_tree_with_article}} helper. Its availability is in the category template only.

    Both of the components are available for Copenhagen Theme so, the theme will not be an issue. To add the helpers you have to edit the code. If you need step by step instructions for it, then you can take a look at this post.

    Let me know if this works for you.

    Thanks

    0
  • Marta Ramos
    Comment actions Permalink

    @Trapta, 

    yes sorry, it doesn't help me cause the post that you linked me is about removing from the home page and also when i add {{section_tree_with_article}} and when I publish it shows an error about not existing.

    But yes i do want to show the list in each category so it will be on the category page. 

    0
  • Trapta
    Comment actions Permalink

    @Marta, I double checked it on my side and this helper is not showing any error while using it in category template. Are you adding it to category template?

    Thanks

    0
  • Marta Ramos
    Comment actions Permalink

    @Trapta,

    it is working I was adding it in the category page but in a weird place and therefore getting an error.

    Thank you.

     

    0
  • Marta Ramos
    Comment actions Permalink

    Hi, @Trapta @Wes again the last tip worked fine but now I also wanted to have something like https://get.slack.help/hc/en-us/categories/200111606 where on the right side shows all the names of the section and shows the active one when scrolling, I don't know if I should leave my question here but do you think you could help me?

    0
  • Amritha Arakali
    Comment actions Permalink

    Hi,

    Can someone please tell me how to show ALL the articles under the section instead of the "show more" link? A code sample would really help.

     

    Thanks

    0
  • Jessie Schutz
    Comment actions Permalink

    Hi Amritha! Welcome to the Community!

    One of our Community members wrote up a Tip on how to do this exact thing! You can find it here. Let us know if you need anything else!

    0
  • Mike Tamosaitis
    Comment actions Permalink

    @wes I have been trying to get your code to work and I am running into an issue. Can you take a look at my page and tell me what I'm doing wrong? I am only trying to see 3 articles on the category page. 

    https://actiontec.zendesk.com/hc/en-us 

    0
  • Mike Tamosaitis
    Comment actions Permalink

    @wes, Thanks that did the trick. 

    0
  • Mike Tamosaitis
    Comment actions Permalink

    @wes, But now on the section page, I only see three articles there. there is no link to show the rest. 

    0
  • Mike Tamosaitis
    Comment actions Permalink

    @Wes I will try this today. I also had the same issue in my sandbox which had the upgraded theme. Thanks again for all your help. I'll let you know how it goes.

    0
  • Mike Tamosaitis
    Comment actions Permalink

    @wes

    I have switched to the upgraded theme in my sandbox to test the settings you gave me and they work thanks again for the help. 

    0
  • Wes Drury
    Comment actions Permalink

    @Mike - glad to hear you got everything sorted.  Best of luck and you know how to reach us if you run into any other issues.

    0
  • Jake Moore
    Comment actions Permalink

    @trapta when using {{section_tree_with_article}} on the Categories page, if the user clicks one of the articles, it displays the full content of the article in-line. Is it possible to simply take the user to that article instead?

    0

Please sign in to leave a comment.

Powered by Zendesk