Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Last link button in header


Question

Site URL: https://www.ahenriksen.com

Hi,

 

I am using the bergen template on a business plan. I have made the page multilingual (english and danish), and originally the template has a button as link in the header. Though being multilingual it says the wording is english and leads to the english contact page on both language versions. I would like it to be in Danish and lead to the danish contact page when on the Danish version of the site.

 

Any suggestions?

Thank you in advance.

Link to post
  • Answers 14
  • Created
  • Last Reply

Top Posters For This Question

14 answers to this question

Recommended Posts

  • 0

You can add some custom JS in the footer. Just update the values of the newLinkPath and newLinkText variables with what you need. 

<script>
  (function(){
    var newLinkPath = '/dk/contact';
    var newLinkText = 'EXAMPLE';

    // The following code below will update url and the text of the CTA link.
    var contactLink = document.querySelector('.header-actions-action--cta a');
    var pathIsDeutsch = location.pathname.indexOf('/dk/') !== -1;
    if(contactLink && pathIsDeutsch){
      contactLink.setAttribute('href', newLinkPath);
      contactLink.textContent = newLinkText;
    }
  })();
</script>

 

Link to post
  • 0

Hi again,

 

I a using google chrome, and inserted the following into the footer:

<script>
  (function(){
    var newLinkPath = '/dk/kontakt';
    var newLinkText = 'Kontakt';

    // The following code below will update url and the text of the CTA link.
    var contactLink = document.querySelector('.header-actions-action--cta a');
    var pathIsDanish = location.pathname.indexOf('/dk/') !== -1;
    if(contactLink && pathIsDanish){
      contactLink.setAttribute('href', newLinkPath);
      contactLink.textContent = newLinkText;
    }
  })();
</script>

Link to post
  • 0
2 hours ago, DanielHenriksen said:

Hi again,

 

I a using google chrome, and inserted the following into the footer:

<script>
  (function(){
    var newLinkPath = '/dk/kontakt';
    var newLinkText = 'Kontakt';

    // The following code below will update url and the text of the CTA link.
    var contactLink = document.querySelector('.header-actions-action--cta a');
    var pathIsDanish = location.pathname.indexOf('/dk/') !== -1;
    if(contactLink && pathIsDanish){
      contactLink.setAttribute('href', newLinkPath);
      contactLink.textContent = newLinkText;
    }
  })();
</script>

You missing a closing script tag for old code

It should be

</script>

<script>
  (function(){
    var newLinkPath = '/dk/kontakt';
    var newLinkText = 'Kontakt';

    // The following code below will update url and the text of the CTA link.
    var contactLink = document.querySelector('.header-actions-action--cta a');
    var pathIsDanish = location.pathname.indexOf('/dk/') !== -1;
    if(contactLink && pathIsDanish){
      contactLink.setAttribute('href', newLinkPath);
      contactLink.textContent = newLinkText;
    }
  })();
</script>

You can send your question to my email to get faster answer. / How to Setup Password & Share URL 

-- I'm Tuan, work for a non-profit project (build free libraries). I check the forum once or twice a day to help out the community. If you don't see me answering your question, you can send it to the email above. 

Link to post
  • 0

Yeah looking at your code, it looks like you may have nested the <script> tag in another <script> tag. Make sure it's outside of the other script tag or you can just place the function in an already existing script tag and forgo the script tags I wrapped in the initial code I provided. 

 

Screenshot_5_29_20__11_53_AM.png

Link to post
  • 0

Hello, 

 

I had the same issue and This was very useful for me. The problem is that I can´t manage to get the right link for the button of the secondary language. How do I change that?

 

Thank you very much!

Link to post
  • 0
11 hours ago, AlbaMarro said:

Hello, 

 

I had the same issue and This was very useful for me. The problem is that I can´t manage to get the right link for the button of the secondary language. How do I change that?

 

Thank you very much!

Can you share site url? We can help easier.

You can send your question to my email to get faster answer. / How to Setup Password & Share URL 

-- I'm Tuan, work for a non-profit project (build free libraries). I check the forum once or twice a day to help out the community. If you don't see me answering your question, you can send it to the email above. 

Link to post
  • 0
39 minutes ago, AlbaMarro said:

This is de Url of my website:

https://www.cameraassistmx.com/es/inicio/

What is password?

You can send your question to my email to get faster answer. / How to Setup Password & Share URL 

-- I'm Tuan, work for a non-profit project (build free libraries). I check the forum once or twice a day to help out the community. If you don't see me answering your question, you can send it to the email above. 

Link to post
  • 0
On 8/27/2020 at 1:09 AM, AlbaMarro said:

estamostrabajando

 

I'm not familiar with the jQuery code you used to create multi language site.

You can use this code to change button link on each page, it's quite manual, you will insert all the pages that you want to change link.

Add to Page Settings > Advanced > Header

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
	$('.header-actions-action a').attr('href','https://beaverhero.com');
});
</script>

replace beaverhero with new url

You can send your question to my email to get faster answer. / How to Setup Password & Share URL 

-- I'm Tuan, work for a non-profit project (build free libraries). I check the forum once or twice a day to help out the community. If you don't see me answering your question, you can send it to the email above. 

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...