Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HomepageLink with the $AbsoluteBaseURL template variable #792

Open
achappard opened this issue Apr 6, 2023 · 8 comments
Open

HomepageLink with the $AbsoluteBaseURL template variable #792

achappard opened this issue Apr 6, 2023 · 8 comments

Comments

@achappard
Copy link

Hello,
I installed Silverstripe 4.12.3 with Silverstripe-Fluent in version 6.0.0. I then configured two languages (fr_FR which is global) and en_US.

In my main layout I try to make a link to the home page with the variable $AbsoluteBaseURL. This link from the fr_FR language is well www.monsite.com. However, if I go to www.monsite.com/en the link to the home page remains www.monsite.com. It should be www.monsite.com/en right?

The only configuration I made is

---
Name: myfluentconfig
---
TractorCow\Fluent\Extension\FluentDirectorExtension:
  disable_default_prefix: true

I think I need to configure Fluent or else Silverstripe but I can't find any documentation about it. Can you help me please?

@tractorcow
Copy link
Collaborator

If you are looking for docs, check the https://github.com/tractorcow-farm/silverstripe-fluent/blob/4/docs/en/configuration.md (and other files in that folder).

Can you verify that fr_FR is set as the global default, and not en ?

@achappard
Copy link
Author

achappard commented Apr 11, 2023

Yes, I checked that as you can see in the attached image. It's really weird.

fluent

I also tried several times to check the url /dev/build?flush

@tractorcow
Copy link
Collaborator

It's possible that it's using en if you have locale detection turned on. i.e. it's using your browser headers to pick the locale, and not the locale prefix.

I believe in fluent 5 we might have changed that behaviour (turned it off).

@achappard
Copy link
Author

Thanks for your investigation @tractorcow but the problem is still there. I reinstalled SS in version 4.12.0, Silverstripe Fluent in version 6.0.0. Here is my configuration file : app/_config/fluent.yml

---
Name: myfluentconfig
---
TractorCow\Fluent\Extension\FluentDirectorExtension:
  disable_default_prefix: false
  detect_locale: false

TractorCow\Fluent\Model\Locale:
  default_records:
    fr:
      Title: Français
      Locale: fr_FR
      URLSegment: fr
      IsGlobalDefault: 1
      Sort: 1
    en:
      Title: Anglais
      Locale: en_US
      URLSegment: en
      IsGlobalDefault: O
      Sort: 2

And when I browse the English version of the site, the link that points to the home page takes me to the French version of the home page. Here is the template code:

<a href="$AbsoluteBaseURL">
    <%t TemplateString.HomePageReturn "Retour à l'accueil" %>
</a>

@achappard
Copy link
Author

Is there a solution to this problem? I think it's a basic thing. If there is no solution, I should go through another solution than SS.

@rasstislav
Copy link

Hi @achappard. I'm using $CurrentLocale.BaseURL, but it's not an absolute URL.
You can create your own template variable for absolute url.

@tractorcow
Copy link
Collaborator

I've added another function for $CurrentLocale.AbsoluteBaseURL #809

@tractorcow
Copy link
Collaborator

Try installing with 6.x-dev and see if it works, @achappard . If you are happy I can tag a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants