How can I change the title of the sidebar?

Beantwortet

14 Kommentare

  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member of The Year - 2021

    Hey Ria Fernandez,

    Just copy the code and paste it at the bottom to your script.js file.

    const sidebarTitle = document.querySelector('h3.lq');
    if (sidebarTitle.textContent.includes('Articles in this section')) {
      document.querySelector('h3.lq').innerText = " Related Articles ";
    }


    SCREENshote:

     

    If any issue feel free to ask :)

     

     

     

    Thanks

    Team

     

     

     

     

    1
  • Ria Fernandez

    Hi Ifra,

    Thanks so much for getting back to me so quickly. I tried out the code and pasted it at the bottom of script.js as recommended, however it didn't change anything. :(

    This is what I see if I inspect the sidebar.

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member of The Year - 2021

    Need to change the class in the code, remove previously added code and add this

    const sidebarTitle = document.querySelector('h3.section-articles__title');
    if (sidebarTitle.textContent.includes('Articles in this section')) {
    document.querySelector('h3.section-articles__title').innerText = "Related Articles";
    }

     

    0
  • Ria Fernandez

    Thank you, Ifra. I've changed the code and added the new one. It's still not working. :(

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member of The Year - 2021
    document.querySelector('h3.section-articles__title').innerText = "Related Articles";

     

    Remove previous and add only this line of code.

    0
  • Ria Fernandez

    Okay sure. It's this: https://support.halaxy.com/

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member of The Year - 2021

    Output:

     

     

     

    Remove previous and add this single line code:

    document.querySelector('h3.section-articles__title').innerText = "Related Articles";
    0
  • Ria Fernandez

    How were you able to get that output? It's still not working. :(

    Am I missing something?

     

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member of The Year - 2021

    Error:

    Causes: https://stackoverflow.com/questions/3143698/uncaught-syntaxerror-unexpected-token

     

     

    Cut the line of code provided by me and paste it at the top to script.js file and then test.

    0
  • Ria Fernandez

    Okay, I have cut and pasted the code to the top of script.js but it is still not working.

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member of The Year - 2021

    Use this code and remove that:

    $(document).ready(function (){
      $("h3.section-articles__title").text("Related Articles")
    })

    Make sure document_head.hbs file must have  CDN:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>



    0
  • Ria Fernandez

    The first code worked! Thank you so much!!

    However, the second code for jquery is making the search bar go all wonky. It doesn't work anymore.

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member of The Year - 2021

    Another way is:

    Go to your article_page.hbs file and add the hard coded string "Related Articles".

    i). Find for {{t 'articles_in_section'}}.

    ii). Then you will get the helper {{t 'articles_in_section'}} inside the '<h3 ..>' tag.

     

     

    iii). Remove  {{t 'articles_in_section'}} and write 'Related Articles'.

     

    iv). You can create DC to show it in multiple languages.

    v). No need to write any code.

     

     

    0
  • Ria Fernandez

    Got it. Thank you so much, Ifra! This has been very helpful. Thank you for your time.

    0

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

Powered by Zendesk