I have two menus. One with countries, one with navigation.
Navigation menu must to have a index link of a active locale. So if I'm at example.com/uk/section and I go to navigation menu and click at index link, I get index of /uk
My countries menu code is:
{% set locales = ['en', 'en_gb', 'sk'] %}
{# Check if locale equals the requested page locale #}
{% if locale == craft.locale %}
{% set current = true %}
{% else %}
{% set current = false %}
{% endif %}
{% set locale = craft.i18n.getCurrentLocale() %}
{% for locale in locales %}
<li>
<a href="{{ craft.config.siteUrl[locale] ~ craft.request.getPath() }}" class="{{ current ? 'uk-active'}}">{{ craft.i18n.getLocaleById(locale).name }}</a></li>
When I try to copy
<a href="{{ craft.config.siteUrl[locale] ~ craft.request.getPath() }}"
class="{{ current ? 'uk-active'}}">{{ craft.i18n.getLocaleById(locale).name }}</a>
and put it to my navigation menu I get
Internal Server Error array_key_exists(): The first argument should be either a string or an integer
Is it fixable or any other way around?
locale
in line 3 have a value? Code looks like there's missing pieces. See this question for a working Language switch solution I use.