marknotton / craft-plugin-agent Goto Github PK
View Code? Open in Web Editor NEWQuery the server-side information from the users agent data.
License: MIT License
Query the server-side information from the users agent data.
License: MIT License
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:
{% set criteria = [
'chrome > 55',
'firefox > 44',
'safari >= 7',
'edge >= 15',
'opera > 50'
] %}
{{ craft.agent.redirect(criteria, 'no-support.twig', 302) }}
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?
Ipad pro does not count as a tablet for some reason.
I've been testing on a ipad pro 12.9 2020.
Any ideas how I can get it to show ipad pros as a tablet? Or is there a way to target all touch devices?
I can't run composer install
or update
anymore because of the missing marknotton/agent
repository. Please can you fix this?
[RuntimeException]
Could not load package marknotton/agent in http://repo.packagist.org: [UnexpectedValueExce
ption] Could not parse version constraint ^3.0.0.*: Invalid version string "^3.0.0.*"
This was working as expected previously, using the "marknotton/agent": "1.1.8"
version.
Good Morning
We use your plugin to detect if a user visits our page with the Internet Explorer Browser.
To check this we do following Check:
{% if craft.agent.check('ie') and not craft.agent.isRobot() %}
{% include '_partials/not-supported.twig' %}
{% else %}
{% include '_partials/navigation.twig' %}
{% block body %}
{% endblock %}
{% include '_partials/footer.twig' %}
{% endif %}
This works fine for the Internet Explorer detection, but the Google Page Crawler get's into this If clause too. So the page is not indexed by Google.
How can we fix this problem?
Please let me know if you need further details.
Kind regard
When updating Craft or installing the plugin, I get the following error:
Error: Could not load package marknotton/agent in https://composer.craftcms.com: [UnexpectedValueException] Could not parse version constraint ^3.0.0.*: Invalid version string "^3.0.0.*"
Getting this on "craftcms/cms": "^3.6.0", PHP 7.4.16
TypeError: floor(): Argument #1 ($num) must be of type int|float, string given in /vendor/marknotton/agent/src/services/Services.php:244
Stack trace:
#0 /vendor/marknotton/agent/src/services/Services.php(244): floor('89.0.4389.82')
...
Its this line:
$this->version = floor($this->agent->version($this->agent->browser()));
When we use
{{craft.agent.check('ie <= 11')}}
And the user agent is not supplied, e.g.
curl --user-agent "" https://example.com/
it will return true when it is supposed to return false.
However, using a magic method like isIE() works
Please let me know if you need further detail.
Right now i am using these criterias for redirecting old ie 11 Browser to the unsupported page.
At least this is how i understand it to work. My Goal is to show users of IE 11 the unsupported message.
Or is there a better way?
{% set criteria = [
'chrome >= 1',
'firefox >= 1',
'safari >= 1',
'edge >= 1',
'opera >= 1'
] %}
{{ craft.agent.redirect(criteria, 'pages/errors/not-supported', 302) }}
But with this implementation, the unsupported message gets also shown, if i user get to the page via
instagram and there in-app browser.
What would be the best solution to include instagram?
thanks.
Sorry if I missed this somewhere, but is it possible to use the redirect
but checked against negative criteria? Right now, it seems like the criteria matches can only be positive. I was hoping to redirect ONLY Internet Explorer to a separate page.
For example, currently, the following only allows Firefox to bypass this no-support
page redirect:
{% set criteria = [ 'firefox' ] %} {# only Firefox is redirected #}
{{ craft.agent.redirect(criteria, 'no-support', 302) }}
It would make more sense to me to have the included criteria be what triggers the redirect:
{% set criteria = [ 'not ie' ] %} {# every browser BUT ie would proceed without redirecting #}
{{ craft.agent.redirect(criteria, 'no-support', 302) }}
Thanks for the plugin and any help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.