Leuchtfeuer / locate

The users country and preferred language and other facts will be detected. Depending on configurable rules the user can be redirected to other languages or pages. New functionality can be added easily.
https://www.Leuchtfeuer.com
GNU General Public License v2.0
9 stars 14 forks source link

Only first hit is redirect correctly in multi page tree setup #19

Closed vaxul closed 3 years ago

vaxul commented 4 years ago

We have a TYPO3 9.5 instance with a multi page tree setup and site handling enabled, so f.e.:

All pages only have one language, the default.

I configured this extension like:

config.tx_locate = 1
config.tx_locate {
  dryRun = 0

  actions {
    redirectToPageDE {
      20 = Bitmotion\Locate\Action\Redirect
      20 {
        page = 30
        cookieHandling = 1
        overrideCookie = 1
      }
    }
    redirectToPageFR {
      20 = Bitmotion\Locate\Action\Redirect
      20 {
        page = 20
        cookieHandling = 1
        overrideCookie = 1
      }
    }
    redirectToPageGB {
      20 = Bitmotion\Locate\Action\Redirect
      20 {
        page = 10
        cookieHandling = 1
        overrideCookie = 1
      }
    }
    redirectToPageUS {
      20 = Bitmotion\Locate\Action\Redirect
      20 {
        page = 1
        cookieHandling = 1
        overrideCookie = 1
      }
    }
  }

  facts {
    browserAccepted = Bitmotion\Locate\FactProvider\BrowserAcceptedLanguage
  }

  judges {
    10 = Bitmotion\Locate\Judge\AndCondition
    10.action = redirectToPageDE
    10.matches (
      browserAccepted.locale = de_DE
      browserAccepted.lang = de
    )

    20 = Bitmotion\Locate\Judge\AndCondition
    20.action = redirectToPageFR
    20.matches (
      browserAccepted.locale = fr_FR
      browserAccepted.lang = fr
    )

    30 = Bitmotion\Locate\Judge\AndCondition
    30.action = redirectToPageGB
    30.matches (
      browserAccepted.locale = en_GB
    )

    40 = Bitmotion\Locate\Judge\AndCondition
    40.action = redirectToPageUS
    40.matches (
      browserAccepted.locale = en_US
    )

    999 = Bitmotion\Locate\Judge\Fixed
    999.action = redirectToPageUS
  }
}

With this configuration, on the first hit (without cookie) the redirect works as expected. Then the cookie is stored with the value "0" for the default language.

I would expect the the 2nd request on the domain would redirect the use to the previous calculated destination.

This doesn't happen, since all pages have the same language "id", the cookies does nothing and the redirect doesn't happen in the 2nd request.

Wouldn't it be better to store the target page UID in the cookie?

flossels commented 3 years ago

I just stumbled across this one. If your issue still exists: If you disable cookie handling, everything should work as desired.