Home Analyst Portal

Is it Possible to Hide the Top Knowledge Articles Section Based on User's Language Selection

Jonathan_BolesJonathan_Boles Customer Ninja IT Monkey ✭✭✭✭
edited June 2016 in Analyst Portal
Good Day Cireson Community,

Our organization is in the process of finalizing the addition of French to our portals - One of the questions posed was is it possible to hide the Top Knowledge Articles section based on the end-user's language selection since the knowledge base articles are not filtered based on language.

Any help or feedback you can provide would be much appreciated!

Best Answer

Answers

  • seth_coussensseth_coussens Member Ninja IT Monkey ✭✭✭✭
    It's definitely possible, but I couldn't tell you the exact amount of work. There are a few ways we could make this work using javascript. Basically, you could  do some of the following:
    - use a custom SO based off the out of the box SO that took this into account (expensive in terms of effort but flexible and allows for other customization as well)
    - Use the custom.js to look at the selected localization and then hide elements that meet a particular criteria. (less expensive but less flexible and could be hard coded into the custom.js in the most expedited version)
    - No customization... use SO permissions to create and create SOs for each language that only contain ROs in the targeted language, and then scope the SO to users that have that language in their user profile.

    Just a few ideas off the top of my head based on things we've seen. Hope this helps.
  • Jonathan_BolesJonathan_Boles Customer Ninja IT Monkey ✭✭✭✭
    It's definitely possible, but I couldn't tell you the exact amount of work. There are a few ways we could make this work using javascript. Basically, you could  do some of the following:
    - use a custom SO based off the out of the box SO that took this into account (expensive in terms of effort but flexible and allows for other customization as well)
    - Use the custom.js to look at the selected localization and then hide elements that meet a particular criteria. (less expensive but less flexible and could be hard coded into the custom.js in the most expedited version)
    - No customization... use SO permissions to create and create SOs for each language that only contain ROs in the targeted language, and then scope the SO to users that have that language in their user profile.

    Just a few ideas off the top of my head based on things we've seen. Hope this helps.
    Hey @Seth_Coussens, So we've done option three for scoping our SOs but I'm thinking more about the Knowledge Base Articles shown that are published using the Cireson Portal KB functionality. We are looking to hide the entire top knowledge base article section if the user logging in has another language besides English set in their portal user settings.

    I'm assuming the middle option might work - using custom.js - have you seen this done before?
  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭
    Hi Jonathan,

    Add this to the custom js 

    formObj.boundReady(function(){
         var user = session.user;
         if (user.LanguageCode == "FRA") {
           //code to hide here
           }
        });

    That will mean it will only run if the current user's language is French.
    Is that more what you were looking for?

    Geoff
  • Jonathan_BolesJonathan_Boles Customer Ninja IT Monkey ✭✭✭✭
    Hi Jonathan,

    Add this to the custom js 

    formObj.boundReady(function(){
         var user = session.user;
         if (user.LanguageCode == "FRA") {
           //code to hide here
           }
        });

    That will mean it will only run if the current user's language is French.
    Is that more what you were looking for?

    Geoff
    Hi @Geoff_Ross, so this will hide the "Top Knowledge Base Articles" section as shown in the attached screenshot? (Only the Top Knowledge Base section needs to be hidden - search should remain)


    SS.png 28.6K
  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭
    That is just a snippet to run a piece of code, ONLY if the user's language is set to French. You will need to wrap that in another snippet to run on the right page and add code in place of '//code to hide here' that actually does the hiding of the KBs.
  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭
    You can use this wrapper to only run the code on the particular page.
    $(window).load(function () {
        if (document.URL.indexOf("/View/94ecd540-714b-49dc-82d1-0b34bf11888f") === -1) {
    
    ......
    
    }
  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭
    And finally, (sorry this answer has come piece by piece over many hours - busy day) this is how you can hide the KB section.

    document.getElementsByClassName("topfav-row")[2].style.display="none"
  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭
    @Jonathan_Boles Any joy?
  • Jonathan_BolesJonathan_Boles Customer Ninja IT Monkey ✭✭✭✭
    @Geoff_Ross, should know tomorrow - just working with development team and haven't had a chance to get back at this quite yet. I really appreciate your help and by the way, great presentation this morning!!
  • Jerry_VeldhuisJerry_Veldhuis Customer Advanced IT Monkey ✭✭✭

    Hi Geoff, I'm helping Jonathan_Boles out with this and hit a snag. Maybe you can point out what I'm doing wrong. Below is the code I've added to the custom.js.

    When I reload the page (with developer mode enabled) I see the following in the console:

    In window.load ok
    In FRA language code
    Uncaught TypeError: formObj.boundReady is not a function

    If I run the

       document.getElementsByClassName("topfav-row")[2].style.display="none"

    in the console after the page has loaded the section disappears, so there must be a bad assumption in here as to when all the elements have loaded.

    ==== CODE ====

    // Changes to out-of-box Knowledge Articles (KBA)
    // For lanugage FRA, hide Top Knowledge Articles line
    $(window).load(function (formObj, viewModel) {
        console.log("In window.load ok")
        if (document.URL.indexOf("/View/94ecd540-714b-49dc-82d1-0b34bf11888f") != -1) {
            //$(document).ready(function () {
            formObj.boundReady(function(){
                var user = session.user;
                console.log("In document ready and on portal home page ok")
                if ( user.LanguageCode == "FRA") {
                    console.log("In FRA language code")
                    document.getElementsByClassName("topfav-row")[2].style.display="none"
                }
                console.log("KBA should now be hidden")
            })
        }
    });

    Appreciate the help.

  • Jerry_VeldhuisJerry_Veldhuis Customer Advanced IT Monkey ✭✭✭
    @Geoff_Ross, when you have a minute, I'd really appreciate some insight into what's wrong with the code above.
Sign In or Register to comment.