Accessing {{category_tree_with_article}} or {{categories}} in header

Answered

4 Comments

  • Justin Palmer

    I know this is an old post, but I'm running into the same problem. Any input, anyone? 

    1
  • Patrick Murray

    Is there a ZenDesk response to this? Adding the ability to put categories in the header would really open up many more navigation options.

    0
  • Rebecca

    Hi all -

    At this time this is not possible. With curlybars, our Help Center templating language certain helpers and objects can only render on certain help center template pages. The best means to see what renders on which page is going to our Help Center templating Developer docs, select the template page in question, and seeing what is listed as available helpers, properties, or objects in the specific template you're working in. Unfortunately, category tree is not an option on the header template at this time.

    However you could likely accomplish a category navigating via custom code in the header itself; I looked around and was not able to find any existing resources on this specific customization, however the options would be coding a navigation menu with href links or possibly using our Help Center API to ensure it's dynamic. 

    0
  • Scott Allison

    Here's some JavaScript that I placed in my script.js file. I added an empty <ul id="support_categories"></ul> element into header.hbs where I wanted my categories menu to be located. Just replace "mysupportwebsite.com" with the domain name of your Zendesk help center.

    var menu = '';
    $.get('https://mysupportwebsite.com/api/v2/help_center/' + window.I18n.locale + '/categories.json', function(data) {
        if (data.categories.length) {
            $.each(data.categories, function(id, category) {
                 menu = menu + '<li><a href="' + category.html_url + '">' + category.name + '</a></li>';
            });
            $('#support_categories').html(menuLinks);
        }
    });

    0

Please sign in to leave a comment.

Powered by Zendesk