Open hhentschel opened 2 years ago
Thanks for the feedback @hhentschel. I've tested the example you've given and it is behaving as expected for me in Craft 3 and 4. I'm not sure I've changed anything regarding the criteria logic following the update.
Using your example; the redirect method translates to:
If the users browser is Chrome 56 or higher, Firefox 45 or higher, Safari 7 or higher, Edge 15 or higher, or Opera 51 or higher, then redirect to the 'no-support.twig' template.
If your expectation is to redirect the users if that criteria does NOT match to the users agent, then you may need to reverse the operators:
{% set criteria = [
'chrome < 55',
'firefox < 44',
'safari <= 7',
'edge <= 15',
'opera < 50'
] %}
However, if you're saying this once worked but no longer in this 4.0.0 release then I will have to investigate it further.
Hi @marknotton , thank for your answer. i am afraid, there is something not working after the update.
i checked it again, with this example, which i translate to: if the users browser is chrome 99 or lower, then redirect to the not-supported.twig page.
{% set criteria = [
'chrome < 100',
] %}
{{ craft.agent.redirect(criteria, 'pages/errors/not-supported', 302) }}
i have chrome 105 and it still redirects me.
thanks for looking into it.
I have the same conditions as you and it's working correctly. Strange!
Sorry to ask, but could you humour me and confirm that you're not testing this on the 'not-supported' page? I've found that I've tested the redirect works and then forgot to return to the initial page when I've amended the criteria settings.
If that's not the case could you confirm your user agent string for me please and I'll check it out?
{{ craft.agent.userAgent }}
I made the same mistake on the first try outs, refreshing the unsupported page, but then i always reloaded the logo, which points to the main page. so, no humor going on here.
i retested, just to make sure, trying to open up the correct url in a new page/tab, but no luck.
i noticed, no matter if i have the "greater than" or "lower than" sign (< or >) it redirects me, with this code:
{% set criteria = [
'chrome > 100'
] %}
{{ craft.agent.redirect(criteria, 'pages/errors/not-supported', 302) }}
Firefox is working with this code above, when i add
'firefox > 100',
(no matter if < or >),
then also firefox redirects me to the to the unsupported page.
here is what the user.agent tells me:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
It's really strange. i tried to test different scenarios. two of my colleagues have the same result.
as this page has different languages i tested them as well, also being logged in and out on the frontend made no difference.
i tried private tabs, also no luck.
Thanks for the details @hhentschel, it helps a lot. My user agent string is identical to yours, so I should be able to replicate your scenario... in theory 😅 I'll continue to experiement and compare with older versions of the plugin.
i have the cookie plugin from nystudio107 installed. could that have any affect?
Hi, have you found anything? i tried it again with no luck. As i actually need only a redirect for ie 11, i tried to use this check: {{ craft.agent.check('ie'}}
by the way, all examples in example 2 are missing a closing bracket.
but its not working in chrome funnily enough. If i check against firefox or safari, i can redirect. but as soon as i have a check, no matter what browser, chrome redirects me to the unsupported page.
maybe that is a hint for you.
thanks for your help!
Apologies @hhentschel for letting this linger on. I will allocate some time to this and see if I can replicate the issue. I recall it coming to a standstill because I just couldn't see what you were seeing. Will give it another shot.
@marknotton any news on that? did you find some time to have another look on that?
Hi, i used the redirect with the criteria method. it all worked fine until i updated to version 4 of the plugin.
Thats what i am using:
Does this version only work with craft 4, as i am running craft 3.7.53.1?
If it should also work with craft 3, did something changed with the criteria method? The docs don't show any difference, but maybe i missed something?