Is there a way to show list of categories/sections in guide theme header.hbs ?

Beantwortet

8 Kommentare

  • Marie-Cathrine
    Community Moderator

    Hi Mike,

    Since you cannot access the category and section helpers from the header, one way to achieve this is by getting the data from the Help Center API using JavaScript and then display it using HTML and CSS.

    You can find the needed endpoints here:

    #helpsome regards,
    Marie-Cathrine Sørensen
    Developer @ helphouse.io

    0
  • Mike

    Thanks for the info. I will give that a try.

    Is there a reason why the categories/sections cannot be made available in the header template?

    0
  • Marie-Cathrine
    Community Moderator

    I do not know the actual reason as to why they cannot be accessed from the header, but according to this comment, it has to do with the curlybars, the Help Center templating language, which only allows certain helpers and objects to render on certain help center template pages.

    If you want to know what can be accessed in which templates, you can find the documentation here.

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member of The Year - 2021

    Hey Mike,

    Go through this article :

    https://support.zendesk.com/hc/en-us/community/posts/360035925193-Show-list-of-all-Posts-on-Home-page-using-API

     

     

    Replace the post list API with the given category  API

    /api/v2/help_center/categories

     

    Keep this given code at the header.hbs file.

    <div class="posts_list">
    <h3>Posts List</h3>
    <ul class="posts-list">
    </ul>
    </div>

     

    See the final result and let me know.

     

    Thanks 

    Team

    1
  • Benjamin BAUDOUIN

    Ifra Saqlain

    your link isn't available anymore : 

    "Hey Mike,

    Go through this article :

    https://support.zendesk.com/hc/en-us/community/posts/360035925193-Show-list-of-all-Posts-on-Home-page-using-API"

    0
  • Brett Bowser
    Zendesk Community Manager

    Hey Benjamin,

    I was able to find a cached version of the tip Ifra previously shared so I've copied the information over here:

    Using this tip , you can show all posts on your home page. You just need to use API of posts list. I used default Copenhagen theme.

    Follow these steps 

    Step 1 : At script.js template ,  copy the code and paste at your script.js file .

        $.getJSON('/api/v2/community/posts.json', function (data) {
    var postsList = '';
    $.each(data.posts, function (idx, itm) {
    postsList += '<li>';
    postsList += '<a href="' + itm.html_url + '" id="' + itm.id + '">'
    + itm.title + '</a>';
    postsList += '</li>';
    });
    $('ul.posts-list').html(postsList);
    var postsLength = $('ul.posts-list > li').length;
    if (postsLength) {
    $('.posts-list').show();

    }
    });

     

    Step 2 : At your home_page.hbs template , copy the given code and paste at your home_page.hbs .

    <div class="posts_list">
    <h3>Posts List</h3>
    <ul class="posts-list">
    </ul>
    </div>

     

    You can see my Home Page :)

     

    Thank You 

    I'll reach out to Ifra to see if she can republish this tip :) 

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member of The Year - 2021

    Thanks so much, Brett I was also finding this tip.

    0
  • Nicole

    I'm trying to add all sections in the side bar on section pages, much like articles in section is listed in the sidebar on article pages (using OOB Copenhagen theme). Any thoughts how to achieve this? It doesn't need to be dropdowns or anything fancy, just looking to get the options in the sidebar (I can play with the CSS later). I'm not having much luck figuring out the code for that one. I'm hoping to list all the sections under the category that the user is currently in. We have a customer-facing category as well as an agent-facing category. Section.sections seems to point and subsections of a section. I'm hoping to link sections of a category. Thanks in advance for any help that can be offered!

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.

Powered by Zendesk