How do I add multilingual welcome note (placeholder text) in search box? (Compenhagen Theme)

Beantwortet

13 Kommentare

  • Trapta
    Aktionen für Kommentare Permalink

    Hi Andreas Ribbfors,

    You might want to take a look at this tip: https://support.zendesk.com/hc/en-us/community/posts/115006078407-Add-multilingual-welcome-note-placeholder-text-in-search-box-along-with-user-name

    Let me know if this solves your issue.

    Thanks

    0
  • Andreas Ribbfors
    Aktionen für Kommentare Permalink

    Thanks for your answer, but I've already checked it out. (Same article as the one I linked to).
    I get it to work on the support tickets, but I don't get the dynamic content to work in guide.


    0
  • Trapta
    Aktionen für Kommentare Permalink

    The screenshot you have attached is showing that you are using one DC in another. Nesting of DC is not allowed in Zendesk.

    Can you share the screenshot of the error it is showing to you?

    Thanks

    0
  • Simon Celen
    Aktionen für Kommentare Permalink

    Hi Andreas,

    If I understand correctly, the "Hello..." placeholder message appears in the search box, but the {{current_user.first_name}} is not replaced by the user's name?

    Assuming you've followed the Add multilingual welcome note (placeholder text) in search box along with user name article then the only thing you need to adjust is marked in bold:

    $(document).ready(function() {
    if(HelpCenter.user.role!='anonymous') {
    var gtext = $("span#dc_greetings_template").data('value');
    gtext = gtext.replace('{{current_user.first_name}}', HelpCenter.user.name);
    $('#query').attr('placeholder', gtext);
    }
    });

    If it's still not working could you paste the location of your Help Center so we can have a closer look?

     

    Thanks

    1
  • Trapta
    Aktionen für Kommentare Permalink

    @Andreas Ribbfors

    In your script.js file replace:

    $(document).ready(function() {
    if(HelpCenter.user.role!='anonymous') {
    var gtext = $("span#{dc.hc_search_greetings_template}").data('value');
    gtext = gtext.replace('{{ {{current_user.first_name}} }}', HelpCenter.user.name);
    $('#query').attr('placeholder', gtext);
    }
    });

    with

    $(document).ready(function() {
    if(HelpCenter.user.role!='anonymous') {
    var gtext = $("span#{dc.hc_search_greetings_template}").data('value');
    gtext = gtext.replace('{{current_user.first_name}}', HelpCenter.user.name);
    $('#query').attr('placeholder', gtext);
    }
    });

    Let me know if this solves your issue.

    Edit: @... got that right.

    Thanks

    0
  • Andreas Ribbfors
    Aktionen für Kommentare Permalink

    I can't get anything dynamic to show in the search bar, just if I put a static placeholder by my self.

    Just to make sure that I understood correctly, as Diziana mentioned in this post,   I'm supposed to add this code in the header.hbs:


    I've also updated the script.js, but it remains the same.

    Thehelp center: https://soluno.zendesk.com/hc/en-gb


    Edit: My home_page.hbs searchfield looks like this:

     

    0
  • Trapta
    Aktionen für Kommentare Permalink

    @Andreas Ribbfors, in your script.js file, try updating the code on line no. 19. Let us know if that helps in with his.

    It looks like you are updating the category block link there but the syntax is not right. It should be document.getElementById('cat-360002138560').attr('href', 'https://www.soluno.se/driftinformation/');

    Thanks

    Team Diziana

    0
  • Andreas Ribbfors
    Aktionen für Kommentare Permalink

    I copied and pasted your code onto line 19, but then the category link stopped working.
    The dynamic placeholder didn't appear either. :/

    0
  • Simon Celen
    Aktionen für Kommentare Permalink

    Hi Andreas,

    In your script.js file at the bottom it should be like this:

    $(document).ready(function() {
      if(HelpCenter.user.role!='anonymous') {
        var gtext = $("span#dc_greetings_template").data('value');
        gtext = gtext.replace('{{current_user.first_name}}', HelpCenter.user.name);
        $('#query').attr('placeholder', gtext);
      }
    });
    1
  • Andreas Ribbfors
    Aktionen für Kommentare Permalink

    @...,
    works great in swedish, but in english it tells me "Could not find the placeholder for dynamic content" (Even though the content exists).

    I also wonder:

    1. Where can I edit the size of the search field? (Widht and height).

    2. How do I set the dynamic content for people who are not logged in?
        Cause now I see the dynamic content, but as logged out it's the standard "Search".

    Edit: I've changed the size of the field and it looks great on the PC, but it's not centered on mobile devices.

    Edit 2: For some reason the menu on cellphones is not clickable.

    0
  • Simon Celen
    Aktionen für Kommentare Permalink

    Hi Andreas Ribbfors,

    That might be because you're viewing your Guide in English (GB) and the Dynamic Content is only set in English (US). You need to add a Dynamic Content variant for every language.

    1. You can edit the CSS on the style.css file in your theme. The exact CSS rules would be a bit out of scope for this board.
    2. You could add a second Dynamic Content item for that, following the same steps as before. This time use dc_greetings_template_anonymous as the span's ID. Then change the script.js snippet to:
      $(document).ready(function() {
      var gtext; if(HelpCenter.user.role == 'anonymous') {
      gtext = $("span#dc_greetings_template_anonymous").data('value');
      }
      else {
      gtext = $("span#dc_greetings_template").data('value'); gtext = gtext.replace('{{current_user.first_name}}', HelpCenter.user.name); }
      $('#query').attr('placeholder', gtext);
      });
    0
  • Andreas Ribbfors
    Aktionen für Kommentare Permalink

    Alright,

    I've added the code but I don't get any content as logged out (it's just blank), as logged in I get everything in Swedish and I always get to the English starting page.

    I've checked the dc and it doesn't specify anything if it's US or GB:


    Here's the new one I've created:

     


    Do I need to change anything in the header.hbs to get this to work or what am I missing?

    0
  • Simon Celen
    Aktionen für Kommentare Permalink

    Hi Andreas,

    Your Dynamic Content it set in "English", while it should be "British English" as that's what you're using on your Guide. You can see this in the URL (https://soluno.zendesk.com/hc/en-gb). Once you fix this you should see the text come up. 

    You may want to confirm the correct settings in https://soluno.zendesk.com/settings/account#localization as well as https://soluno.zendesk.com/hc/admin/language_settings

    0

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

Powered by Zendesk