Customizing the Settings panel (Guide Professional and Enterprise)

Have more questions? Submit a request

38 Comments

  • Devan
    Comment actions Permalink

    Hello David Coleman,

    Glad you were able to figure this question out on your own! Sound's like a boom moment indeed, but if you ever have any more questions on Guide customizations, let us know, and we would be happy to assist!

    Best regards. 

    0
  • David Coleman
    Comment actions Permalink

    I have been successful creating settings and accessing them from templating, but is it possible to access the manifest-settings from JavaScript? If so, please share an example. 

     

    Thank you.

    0
  • Simon Blouner
    Comment actions Permalink

    To the best of my knowledge, this is not possible - I believe it's only possible to do it by importing/exporting your themes.

    If it's possible, it's probably going to be by some crazy workaround.

    If someone can present a simple solution to this from the Guide admin area, I'll buy that person a beer :-D

    0
  • Simon Celen
    Comment actions Permalink

    Hi David,

    It's possible to add something like this f.e. to your footer.hbs:

    <script type="text/javascript">
    var foo = {{json_stringify settings.foo}};
    </script>

    You then have a global foo variable with the value of settings.foo.

     

    A more versatile approach for when you have a bunch of settings is to instead add:

    <script id="settings" type="application/json">{
    "foo": {{json_stringify settings.foo}},
    "fum": {{json_stringify settings.fum}}
    }</script>

    ... and in your JS:

    jQuery(document).ready(function($) {
    var json = $('script#settings').html();
    var settings;
    try {
    settings = JSON.parse(json);
    }
    catch (e) {
    settings = {};
    console.error('could not parse JSON in script#settings', e, json);
    }
    });

    which gets you an object with all the individual settings.

    Hope that helps!

     

    PS @Simon, not 1-upping you of course. It's just that I have a bot crawling all Support pages for the text "free beer" and the likes ;-)

    0
  • David Coleman
    Comment actions Permalink

    Very cool and creative Simon!

     

    Thank you both for taking the time.

     

    - David

     

    0
  • Katerina Benova
    Comment actions Permalink

    Hi,

    I'm trying to use a manifest variable in the home-page template using {{settings.category1_id}} to compare the category ID with the variable I set in the manifest.

    I've followed: https://developer.zendesk.com/apps/docs/help-center-templates/objects#settings-object

    it works fine when I have {{#is ../settings.category1_id "360001821732"}} - using a string, but it doesn't work when I use number {{#is ../settings.category1_id 360001821732}}, so it seems that comparing a value "string" with a value "number" is the problem. Any way to set the manifest variable value as an integer?

    Manifest file: 

    {
    "identifier": "category1_id",
    "type": "text",
    "description": "ID of the first category on Homepage",
    "label": "Category 1",
    "value": "360001821732"
    }

    if I try "value": 360001821732 there is a "property error" when I try to import it to Zendesk

    Here is a code from my homepage I have now (and it's working)

    {{#each categories}}
    {{#is id 360001821732}}

    (BTW {{#is id "360001821732"}} is not working)

    And here is what I'd like to have but is not working

    {{#each categories}}
    {{#is id ../settings.category1_id}}

     

     

    0
  • Simon Celen
    Comment actions Permalink

    Hi Katerina,

    Unfortunately that's not possible because there is no "integer" setting type. The {{#is}} helper compares both values by identity, like === in Javascript instead of equality ==, and '123' !== 123 as you know.

    There currently is no solution for this as far as I know. You'll have to resort to hardcoding the ID in the template.

    0
  • Katerina Benova
    Comment actions Permalink

    Hi Simon,

    Thank you for your fast answer.

    Too bad it is not possible. I was hoping to avoid the hard coding in the template.

    0

Please sign in to leave a comment.

Powered by Zendesk