{"id":23631164,"url":"https://github.com/philecms/phileuseragent","last_synced_at":"2025-11-08T11:30:36.981Z","repository":{"id":11820909,"uuid":"14372915","full_name":"PhileCMS/phileUserAgent","owner":"PhileCMS","description":"a useragent sniffing plugin for Phile that exposes data to the template","archived":false,"fork":false,"pushed_at":"2014-06-19T13:25:41.000Z","size":246,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-28T02:48:48.056Z","etag":null,"topics":["philecms-plugin"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PhileCMS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-13T18:42:55.000Z","updated_at":"2018-03-15T13:41:23.000Z","dependencies_parsed_at":"2022-09-14T12:01:00.403Z","dependency_job_id":null,"html_url":"https://github.com/PhileCMS/phileUserAgent","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhileCMS%2FphileUserAgent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhileCMS%2FphileUserAgent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhileCMS%2FphileUserAgent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhileCMS%2FphileUserAgent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PhileCMS","download_url":"https://codeload.github.com/PhileCMS/phileUserAgent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239551932,"owners_count":19657818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["philecms-plugin"],"created_at":"2024-12-28T02:48:56.230Z","updated_at":"2025-11-08T11:30:36.752Z","avatar_url":"https://github.com/PhileCMS.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"phileUserAgent\n==============\n\nA plugin for [Phile](https://github.com/PhileCMS/Phile) to expose browser user-agent data to the template.\n\n### 1.1 Installation (composer)\n```\nphp composer.phar require phile/user-agent:*\n```\n### 1.2 Installation (Download)\n\n* Install the latest version of [Phile](https://github.com/PhileCMS/Phile)\n* Clone this repo into `plugins/phile/userAgent`\n\n### 2. Activation\n\nAfter you have installed the plugin. You need to add the following line to your `config.php` file:\n\n```\n$config['plugins']['phile\\\\userAgent'] = array('active' =\u003e true);\n```\n\n### Usage\n\nThis plugin will create a new variable in your template called `{{ useragent }}`.\n\nYou can use this varaible to load conditional content, add special classes, or even modify your javascript.\n\n#### Exposed Infomation\n\nHere is an example (from my laptop) of the full useragent array:\n\n```php\narray(\n  'useragent' =\u003e 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.6 Safari/537.36', // full useragent string\n  'name' =\u003e 'Google Chrome', // name of the browser\n  'browser' =\u003e 'google-chrome', // css safe browser name\n  'version' =\u003e '32.0.1700.6', // browser version number\n  'type' =\u003e 'desktop', // form factor browser || mobile\n  'platform' =\u003e 'mac', // Operating System\n  'pattern' =\u003e '#(?\u003cbrowser\u003eVersion|Chrome|other)[/ ]+(?\u003cversion\u003e[0-9.|a-zA-Z.]*)#' // regex pattern that matched\n);\n```\n\n#### Conditional Content\n\n```html\n{% if useragent.type == 'desktop' %}\n  \u003cdiv class=\"desktop-header-image\"\u003e\n    \u003cimg src=\"images/desktop.jpg\" alt=\"desktop screenshot\"\u003e\n  \u003c/div\u003e\n{% else %}\n  \u003cdiv class=\"mobile-header-image\"\u003e\n    \u003cimg src=\"images/mobile.jpg\" alt=\"mobile screenshot\"\u003e\n  \u003c/div\u003e\n{% endif %}\n```\n#### Special Classes\n\n```html\n\u003cbody class=\"{{ useragent.platform }} {{ useragent.type }}\"\u003e\n  \u003cdiv class=\"content\"\u003e\n    {{ content }}\n  \u003c/div\u003e\n\u003c/body\u003e\n```\n\n#### Javascript Additions\n\nIf we put this code in the *head of our document*, we can encode the `{{ useragent }}` array as json and use it in our javascript:\n\n```javascript\n\u003cscript type=\"text/javascript\"\u003e\n  window.Phile.useragent = {{ useragent|json_encode() }};\n\u003c/script\u003e\n```\n\nNow `Phile.useragent.browser` would return the CSS safe browser name in our javascript.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilecms%2Fphileuseragent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilecms%2Fphileuseragent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilecms%2Fphileuseragent/lists"}