viso Posted February 21, 2022 Share Posted February 21, 2022 Site URL: https://www.atelierviso.com Hi all, I'm a new user to Squarespace Forum and I'm looking for some help. I customized my Marta template with some CSS codes I found from tutorials. After some trial and error it actually works quite fine except of two bugs I cannot figure out: 1. When I click Language>Deutsch in my main navigation it changes to german, which is perfect BUT as soon as I click on "Deutsch" again, it changes back to english instead of staying german. What can I do to keep it in german? 2. When I click one of the options/pages in my primary navigation, all pages appear, which should not be the case. One language should always be disabled. What can I do to keep the chosen language? To give you an better understanding, this is what I did: - Changed all URL-slugs in pages depending on the language i.e. /en/home for english; /dt/home for german and so on... - This is the Code I copied in Settings>Advanced>Code Injection>Footer: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(function() { /* SETUP MULTI-LANGUAGE */ var defaultLanguage = 'en'; var lang = location.pathname.split("/")[1]; var defaultClass = 'lang-'+defaultLanguage+''; var itemParent = "nav [class*='collection'],nav [class*='folder'],nav [class*='index'],nav [class*='group']"; if (lang == "" || lang.length > 2 ){ var lang = defaultLanguage; } /* ADD LANGUAGE CLASSES */ $('a[href="/"]').addClass('lang-'+defaultLanguage+'').parents(itemParent).addClass('lang-'+defaultLanguage+''); $('nav a:link:not([href^="http://"]):not([href^="https://"])').each(function () { var langType = $(this).attr('href').split("/")[1]; var multiLanguageClass = 'multilanguage lang-' + langType + ''; if (undefined !== langType && langType.length <= 2) $(this).addClass(multiLanguageClass).parents(itemParent).addClass(multiLanguageClass); }); $('nav button').each(function () { var langTypeFolder = $(this).attr('data-controller-folder-toggle').split("/")[0]; var multiLanguageClass = 'multilanguage lang-' + langTypeFolder + ''; if (undefined !== langTypeFolder && langTypeFolder.length <= 2) $(this).addClass(multiLanguageClass); }); /* HOMEPAGE-LOGO LINKS TO PROPER LANGUAGE HOMEPAGE */ if (lang == "dt") { $('a[href="/"]').attr("href", "/home"); } /* ADD EXCLUSION NAV ITEMS */ $('.exclude-me,.exclude-me a').addClass('exclude'); $('.sqs-svg-icon--list a,.SocialLinks-link').addClass('exclude'); /* REMOVE OTHER LANGUAGES AND KEEP EXCLUDED ITEMS */ $('.multilanguage:not(".lang-'+lang+',.exclude")').remove(); }); </script> My website is - www.atelierviso.com Any suggestions and answers will be highly appreciated, thanks! PS: I didn't translate the different pages to german yet. 😉 Link to comment
Solution paul2009 Posted February 25, 2022 Solution Share Posted February 25, 2022 See my answer here: viso 1 About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥. Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links. Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional. Link to comment
viso Posted March 7, 2022 Author Share Posted March 7, 2022 @paul2009 It worked!! Thank you so much!! 🙌 Link to comment
paul2009 Posted March 7, 2022 Share Posted March 7, 2022 10 minutes ago, viso said: Thank you so much!! 🙌 🙂 You're welcome. About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥. Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links. Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment