Help Center JavaScript cookbook (Guide Professional and Enterprise)

Have more questions? Submit a request

52 Comments

  • Dan Ross
    Comment actions Permalink

    Hi anyone at Zendesk,

     

    Is there a list or where we can see what the different sections are called?

    eg

    #request_subject

    #request_description

    #Some_other_attribute?

     

    Also, does dynamic content render in JS? Trying to add a dynamic header to a field, but running into difficulty.

    1
  • Ian Maison
    Comment actions Permalink

    Hi, we have been using curlybars to exclude articles from Categories/Sections/Article List, which is working, however we would like to exclude the articles from the Search Results which seems impossible to achieve.

    I’ve looked at User Segments for the Section (where all articles sit) and this does not achieve what we need as we don’t wish to restrict users in any way if they have the direct URLs, just that they should not be capable of seeing them within the Help Centre or the search results.

    Speaking with Zendesk Support they state that custom JS code could be used to achieve this, but they don’t provide any pointers how. Does anyone have advice on how this would be achieved?

    How would I exclude certain search results from being shown?

    Any assistance would be welcomed. Thank you.

    1
  • Charles Nadeau
    Comment actions Permalink

    Hi KC,

    The cookbook relies heavily on jQuery. The Copenhagen v2 theme removed the jQuery library but you can add it back. Here are the instructions:

    https://support.zendesk.com/hc/en-us/articles/360037983854-Importing-or-upgrading-jQuery

    Thanks.

    1
  • Brett - Community Manager
    Comment actions Permalink

    Hey Ron,

    I myself am not very experienced in this area, however, I did a quick Google search and was able to find the following discussion on Stack Overflow: Popup on website load once per session

    Perhaps that will help? Hopefully, others can jump in and offer up some guidance for you as well.

    Cheers!

    1
  • Kristin Z.
    Comment actions Permalink

    Hi,

    I am creating my own dropdown menu instead of using {{user_info}}, because we want that menu to have additional links. How would I generate a link to "My Profile"? I tried {{link 'user_profile'}} but an ID is required. Can anyone help? I have searched and searched and can't seem to find an answer anywhere I look. :(

    thanks!

    1
  • Jessie Schutz
    Comment actions Permalink

    Hi Ian!

    Hopefully someone here in the Community can help you with this code. I'll check with our Community Moderators to see if one of them can help as well!

    1
  • Jessie Schutz
    Comment actions Permalink

    Hey Jimmy!

    I'm sure it's possible to write some JS to do that, although we don't currently have any tutorials to that effect. I've pinged our Community Moderators about your question; hopefully one of them will be able to share some insight!

    1
  • Jon Daniels
    Comment actions Permalink

    Hey, Dan!

    Unfortunately, you won't be able to add a dynamic header to a field, but the naming convention of these fields is essentially request_ and then the field name as outlined in our core API documentation for tickets here:

    Zendesk API - Tickets

    You can always view the source of the New Request page if you would like to be sure of the section names.

    Hope this helps! 😺

     

    1
  • Jessie Schutz
    Comment actions Permalink

    Hey Dan! Sorry this fell through the cracks the first time you posted it; I removed the older duplicate just to keep things tidy.

    I don't actually know the answer to your questions, so I'm going to bring in someone from our support team to help out. Stand by!

    1
  • Jimmy Bowers
    Comment actions Permalink

    Hi All,

    I have enabled the ability to hide the subject/description on our custom form in Help Centre, however I was really hoping there is some JS that someone could help me with so I can get an image to appear if the user select a form.  For example, they select a "IT Support" custom form, and an image appears for that form selection with a process diagram.

    Thanks!

    1
  • David
    Comment actions Permalink

    Is there a way to have an element appear when one language is selected but not for another?

    For example - I've added a floating mailto link img for each page. But I want this to link to one address for English, and another address for other languages.

    So I need a different element defined for other languages. I want to have one appear when English is selected, but another appear when another language is selected.

    How is this possible?

    1
  • Jessie Schutz
    Comment actions Permalink

    Hi Zoe! 

    I don't think we have any tutorials that show how to do this, but we do have a tip that shows how to hide the submit a request link for non-logged in users. It's not the exact same thing, but it might be a good jumping off point!

    0
  • Diziana
    Comment actions Permalink

    Hi Ron

    Please read the post here: https://support.zendesk.com/hc/en-us/community/posts/360031296373-Do-you-use-moment-js-in-your-Theme-Has-it-been-broken-in-last-couple-of-days-

    Please send us an email (https://support.diziana.com/requests/new), share your multilevel-menu plugin with us, and we will share an updated version that works. We have raised ticket with Zendesk, and we are requesting them to fix this issue -- that is scope their version of moment to their own code, not let it override code used in help-center themes.

    Thank you

    0
  • KC
    Comment actions Permalink

    Hi - when I add

    $(document).ready(function() 

    to my script.js file (it's not there in the latest Copenhagen theme), the user info dropdown stops working. Does anyone know how to fix this?

    0
  • Zoë Rowley
    Comment actions Permalink

    Hello wise people,
    I would like to add some info above the Submit button on our new request form (I have been able to add info to the attachment area), and hoping someone can help me out.

    The code for the extra text on the attachment field is (I am hoping I can change the bold bit to the Submit button ID but I cannot seem to find it) ;

    <script>
    if(window.location.href.indexOf("formID") > -1) {
    $('div#upload-dropzone').parent().find('label').text('Text to add here')
    }
    </script>

    Any help is welcome. Z

    0
  • Ram Claudio
    Comment actions Permalink

    Hello Saranya,

    As I have validated multiple custom themes, this should already show up in your script.js template found at the bottom of the selection when you edit the Code of your custom theme. If it's not there, you can simply add this: $(document).ready(function() at the top of your script.js template.

    Hope this helps!

    0
  • Joachim Shotter
    Comment actions Permalink

    Is there a way to add a custom ID through JavaScript to the list items on the homepage. So I can reference them within the CSS without adding code to the template pages? I would also like to do this with the site header title. {{help_center.name}}

    $( '.blocks-item' ).prepend( 'CUSTOM ID' );

     

    <li class="blocks-item" id="CUSTOM ID">


    /* CUSTOME ID */
    #category_id_360000809844 a:before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size:60px;
    content: "\f007";
    }

    0
  • Zoë Rowley
    Comment actions Permalink

    Hi,
    We would like our language picker to appear only on the submit a request page header ... what would be the best way to do this?

    Cheers,

    Zoe

    0
  • Trapta
    Comment actions Permalink

    Hi @Tomasz Eitner,

    As far as I know, there is no such option to show other forms than the default form but, you can update the links that redirect to new request form by adding ticket_form_id in the URL to always redirect users to the selected form.

    You can also hide the drop-down of forms list to prevent users from selecting other forms.

    Thanks

    Team Diziana

    0
  • Madison Davis
    Comment actions Permalink

    Hi Luiz! Great question. As the attachment field exists, users can upload more than one file - if that doesn't suit your need, could you outline what you're looking for instead?

    0
  • Trapta
    Comment actions Permalink

    Hi @Kimberly,

    You can simply edit the language selector code in your .hbs file and replace {{current_locale.name}} with {{#is current_locale.name 'Spanish (English)'}} English {{else}} {{current_locale.name}} {{/is}}

    Also, replace {{name}} with {{#is name 'Spanish (English)'}} English {{else}} {{name}} {{/is}}

    Let me know if this solves your issue.

    Thanks
    Team Diziana

    0
  • Jimmy Bowers
    Comment actions Permalink

    Thanks, Jessie.  Hopefully someone can spare a bit of help :)

    0
  • Gef Faelden
    Comment actions Permalink

    Our subject field is currently not shown to end users. Is there a recipe for assigning the ticket subject based on the value of the custom field?

     

    Thanks

    0
  • Tomasz Eitner
    Comment actions Permalink

    Hi @Trapta,

     

    Thanks for a tip . I have linked it directly with ticket form ID.

     

    How can I hide the drop down ? 

     

    Thanks

    0
  • Kimberly Jacksteit
    Comment actions Permalink

    Hello everyone, 

    We have 2 languages in one of our our help centers ("Spanish" and "Spain (Spanish)") - We need to change the display name for "Spanish" in the language selector from "Spanish" to "English" (we provide our own translations and due to a limit in the languages we are able to use in our help centers, we've recently been needing to re-purpose some languages and therefore must rename the display name). We've successfully used the below code to make this change in other help centers, but because the 2 languages both have the word "Spanish", this code is changing both display names. Does anyone know a better way to change the display name in this type of situation? 

    $(function(){
    $('a.dropdown-toggle:contains("Spanish")').text("English");
    $('a:contains("Spanish")').text("English");
    });

     

    0
  • Jennifer Rowe
    Comment actions Permalink

    Chuck, 

    Glad to hear you figured it out.

    Thanks for coming back and sharing your solution!

    0
  • Trapta
    Comment actions Permalink

    @Tomasz Eitner,

    You can put this code at the bottom of your style.css file to hide the drop down

    .form-field.select.optional.request_ticket_form_id {
    displaynone;
    }
    0
  • Ron de Vries
    Comment actions Permalink

    Hi Brett, 

     

    Thanks. I will look into that post on Stack Overflow! 

    Cheers!

    0
  • Brett - Community Manager
    Comment actions Permalink

    Hi Zoë,

    Have you had a chance to look at the following post? Add description to the Attachments field for "Submit a request" form

    It looks like Diziana provided some code that can help with adding a descriptions to your field.

    I hope this helps!

    0
  • Brett - Community Manager
    Comment actions Permalink

    Hi Stan,

    Hopefully some of our community members can jump in here and offer up some advice on how to use IntroJS with the Help Center. I'll also add this post to the March Community Roundup to help provide visibility for you as well :)

    Cheers!

    0

Please sign in to leave a comment.

Powered by Zendesk