Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Language in url with base_url variable

Started by Muut Archive 11 years ago · 1 replies · 765 views
11 years ago

Hi,

there is a litle problem with the antimatter theme in url when you specify one or more languages. In my case, I specified french language (fr) only and choose FALSE for include_default_lang variable in admin plugin.

Then, all url are displayed without locale, excepted url using base_url, base_url_relative or base_url_absolute variables. With these variables, the locale is added in urls!

I solved the problem using this code in twig template:

TWIG
{% if config.system.languages.include_default_lang == false %}
    {% set lang = grav.language.getActive() %}
    {% set search = '/'~lang~'/' %}
    {% set base_url_relative = base_url_relative.replace({(search):'/'}) %}
{% endif %}

But I think there is a better way to do this? By modifying all base_url... variables programmatically? Using a redirection?

Thx for your help

11 years ago

Actually it's not an issue for Antimatter, it's a core Grav thing. I think if include_default_lang is set to false, the base_url type URLs shouldn't have the language code in them.

Can you please submit an issue here: https://github.com/getgrav/grav/issues

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1351 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4062 9 years ago
Archive · by Muut Archive, 9 years ago
1 2948 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago