Help center templating cookbook

Return to top

11 Comments

  • Catherine Michalak
    Community Moderator

    Hi,

    Is there anyone who could help me add subsections to my custom HC code?

    I am struggling to get the section with subsections to show if it doesn't have an article in it (ie. the subsections have articles but until there's an article in the section itself, it doesn't show on the category page) and struggling to keep the layout the same on the section with subsections level as it is on the category with sections level.

    TIA!

    Catherine

     

    0
  • Emelie Stjernquist

    Hello @...,

    Just so I get it right, you wish to display an "empty" section?

    I'm not sure that that is possible to do (at least I've not manage to do that), however I have a suggested work-around which is to:

    1. Create an Article on the Section you wish to display (one that is OK to find if found via search function)
    2. Create a custom Section-template where you modify the html, remove the part that displays/list the articles - Guide from Zendesk help
    3. Edit the Section and assign the new template and publish the Section and Article

    I usually elaborate, test back and forth in the templates until I get the result I want. You can also preview it in "Preview mode" before publishing it.

     

    I hope this helps you to get closer to what you wish to accomplish, good luck!

    //Emelie

    0
  • Francois S

    The Current_local.name trick isn't working. 

    I'm using this list: https://support.zendesk.com/hc/en-us/articles/203761906-Zendesk-language-support-by-product

    And for some reason, the rename of the "language" is working for English (World) that is defined as a "Variant" but all the other ones, aren't working (Estonia, Lithuania, Latvia, Luxembourg,...)

    <button class="dropdown-toggle" aria-haspopup="true">
    {{#is current_locale.name 'English (Luxembourg)'}}
    Test
    {{else}}
    {{current_locale.name}}
    0
  • Augusto Silva
    Zendesk Engineering

    Hey @...

    Try something like this instead (language names can change):

    {{#contains current_locale.url "/en-us"}}
    true
    {{else}}
    false
    {{/contains}}
    0
  • blak3r

    My Activities has `{{requests}}` template variable on it.  The Home Page does not.  Is there a simple way to expose the `{{requests}}` to the home page for signed in users?

    I'd like to show them their 5 most recent requests on the homepage so it's more visible.

    If that cannot be done, could a Custom Page do this?  Essentially I want a landing page from our product for support that has both their requests and then knowledge base shown under it.  One stop landing page from my product.  We use SSO so our users are already authenticated when going there from the app.

    0
  • Greg Katechis
    Zendesk Developer Support Team

    Hi Blake! I thought about this for a bit to see if I could get creative, but there isn't any way that I could envision where this could be accomplished. As you noted, `{{requests}}` don't exist in the home page template and custom pages also do not contain that helper. I wish I had better news and if I think of anything, I'll drop you a line here.

    0
  • blak3r

    Greg Katechis - thanks for giving it some thought.  I suppose this would need to be accomplished with custom javascript to call an api endpoint we'd host that would then use the REST api and return the data back.  Blockers here: 1) simple documentation showing how to add javascript that invokes web requests to a third party server 2) Any tips on how we could authenticate on our server code that the user account is in fact authenticated... like if we had /api/getTickets?user=<emailAddress> we need to verify the user is in fact logged into zendesk somehow so they couldn't exploit the api to get other peoples tickets. 

    0
  • Greg Katechis
    Zendesk Developer Support Team

    1) For this, you could just make an AJAX request from the custom code in your help center to initiate this call to your server/middleware. While it isn't the exact scenario that you're looking to accomplish, this article should give the basic framework that you would need and then you can just swap out your URL/endpoint.

    2) This one is giving me all sorts of problems...both from a basic implementation standpoint, but especially from a security standpoint. We don't have any method of using OAuth in Guide, which would be the easiest way to accomplish this. You could also use the signed_in helper to confirm that someone is signed in and then grab the CSRF token to do...something clever? Like I mentioned, I don't feel comfortable with this, but maybe the idea would spark something in someone else to a function solution!

    0
  • blak3r

    Thanks Greg. Appreciate the link and the quick response. Maybe I can get a value that is set by the login to uniquely identify the session or something. I’ll hack around. I could provide a token in the return_to portion of the jwt flow. Then modify every page template to store that token in a cookie. And pass that along with server Ajax calls and of course have that same token stored in the user db for checking against. Or maybe just the primary entry point page and have it only work if they redirected there. I’ll sleep on it.

    1
  • Greg Katechis
    Zendesk Developer Support Team

    Oh that's a great idea if you use JWT! I wouldn't recommend storing the token in the DB, as that will change on each login, but you could use the shared secret from Zendesk to verify the signature on your server. The JTI might cause a problem, although if you're just storing that as a cookie and not doing any authentication/authorization in the traditional sense, this could work.

    Let me know if you get this working or hit any snags with this. This could be a great tip for other users looking for a similar solution!

    0
  • blak3r

    It appears the jwt token is stored in an object in ```Session Storage.z2_sunco_widget_auth.jwt```

    So, in the requests to our server we could include the users email, jwt, and the JTI.  The server would take the JTI and resign the payload.  If that payload matched the jwt supplied with the request then we could assume that the user was in fact the email provided to the request.

    In terms of how to get the JTI, there are two approaches I see... 
    1. Store the JTI in our user table each time a request is built... Con here is possible synchronization issues. For example, we were planning on having links in our product just include the jwt to avoid any perceived glitchy redirect behavior from enduser standpoint.  For example to go to /hc/article/103 our link would be https://subdomain.zendesk.com/jwt?jwt=<token>&return_to=https://subdomain.zendesk.com/hc/article/103

    2. Pass the JTI as a GET param in the return_to and store that to a cookie with custom Javascript code on each page template.  CON here is long urls look gross and add potential for user to bookmark a link with a JTI in it... Probably could mitigate this by updating the url.  

    3. Get our helpdesk working on a subdomain of our domain.  Use https://support.mydomain.com instead of https://<zdsubdomain>.zendesk.com and have our webapp set a cookie to root domain that the zendesk code could also see. Probably the best option.

    Questions for you... is this z2_sunco_widget_auth a reliable key for the JWT token?  That sunco part is throwing me off.  Also, I'm not a JWT security specialist, I can't see why having the JTI exposed would be that insecure... given you can't sign a payload without the shared secret but maybe i'm missing something.  Feel free to DM me personally if you prefer.

    0

Please sign in to leave a comment.

Powered by Zendesk