DanielHenriksen Posted May 27, 2020 Share Posted May 27, 2020 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 comment
tuanphan Posted May 28, 2020 Share Posted May 28, 2020 Change text or Change link or change both? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
jpeter Posted May 28, 2020 Share Posted May 28, 2020 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> Full stack developer who loves helping people out with anything web related. If you'd like to support me, buy me a coffee! Link to comment
DanielHenriksen Posted May 28, 2020 Author Share Posted May 28, 2020 Thank you for the replies. I want to change both link and text. @jpeter it doesn't quite seem to work even though i updated path and text. I'm using V7.1 could that be the reason? Link to comment
jpeter Posted May 28, 2020 Share Posted May 28, 2020 @DanielHenriksen I was able to get it working by running the function directly in my Chrome browser, see screenshot. A couple questions: What browser are you using? Could you paste the code you tried adding? Full stack developer who loves helping people out with anything web related. If you'd like to support me, buy me a coffee! Link to comment
DanielHenriksen Posted May 29, 2020 Author Share Posted May 29, 2020 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 comment
tuanphan Posted May 29, 2020 Share Posted May 29, 2020 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> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
jpeter Posted May 29, 2020 Share Posted May 29, 2020 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. Full stack developer who loves helping people out with anything web related. If you'd like to support me, buy me a coffee! Link to comment
DanielHenriksen Posted May 29, 2020 Author Share Posted May 29, 2020 Yes, that was it. Thank you I appreciate it. Link to comment
AlbaMarro Posted August 25, 2020 Share Posted August 25, 2020 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 comment
tuanphan Posted August 26, 2020 Share Posted August 26, 2020 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. Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
AlbaMarro Posted August 26, 2020 Share Posted August 26, 2020 This is de Url of my website: https://www.cameraassistmx.com/es/inicio/ Link to comment
tuanphan Posted August 26, 2020 Share Posted August 26, 2020 39 minutes ago, AlbaMarro said: This is de Url of my website: https://www.cameraassistmx.com/es/inicio/ What is password? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
tuanphan Posted August 28, 2020 Share Posted August 28, 2020 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 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.