A helper Plone extension which makes easier to include resources specific to several types of browsers or platforms.
Project description
About
A helper Plone extension which makes easier to include resources like CSS, JS, KSS or HTML specific to different types of browsers or platforms.
Installing
This package requires Plone 3.x or later (should work with 2.5.x also).
Installing without buildout
Install this package in either your system path packages or in the lib/python directory of your Zope instance. You can do this using either easy_install or via the setup.py script.
After installing the package it needs to be registered in your Zope instance. This can be done by putting a collective.browserdetector-configure.zcml file in the etc/package-includes directory with this content:
<include package="collective.browserdetector" />
or, alternatively, you can add that line to the configure.zcml in a package or Product that is already registered.
Installing with buildout
If you are using buildout to manage your instance installing collective.browserdetector is even simpler. You can install collective.browserdetector by adding it to the eggs line for your instance:
[instance] eggs = collective.browserdetector zcml = collective.browserdetector
The last line tells buildout to generate a zcml snippet that tells Zope to configure collective.browserdetector.
If another package depends on the collective.browserdetector egg or includes its zcml directly you do not need to specify anything in the buildout configuration: buildout will detect this automatically.
After updating the configuration you need to run the ‘’bin/buildout’’, which will take care of updating your system.
Usage
There are several browsers, mostly older releases, which renders websites in different way then common browsers of latest versions. So in case you need to support these browsers with your website, one possible way how to include fixes for their different behaviour is to include individual resources targeting specific browsers.
Plone by default includes IEFixes.css file (with a few others) where are fixes / hacks related to all IE browsers for example, but what if you need different fixes for each IE version? There comes collective.browserdetector in turn.
1. Lazy way (quick & start)
install browser detector via Quick Installer
go to ZMI:/portal_skins/collective.browserdetector
select css module for your browser (by its name) and customize it
add your css hacks into customized css file
go to ZMI:/portal_css and register your new resource, see example of generic setup configuration::
<stylesheet title="" id="IE6.css" media="screen" rel="stylesheet" rendering="import" cacheable="True" compression="safe" cookable="True" enabled="1" expression="python:portal.restrictedTraverse('@@browser-detector').isIE6"/>
don’t forget to set the right expression, but don’t worry the only thing which you have to take care is its last part “isIE6” in this example, you should use the right detector attribute according to targeting browser (list of available detector attributes is included below)
And that’s it.
2. Using policy or theme
register collective.browserdetector as dependency of your policy package (in the metadata.xml profile module)
include your css files with fixes in the skin layers (you can copy prepared css files from collective.browserdetector/collective/browserdetector/skins/collective.browserdetector)
register your css files via generic setup (see collective.browserdetector/collective/browserdetector/profiles/default/cssregistry.xml.example for an example)
And that’s it.
3. Detector attributes
Here are available detector attributes usable for conditions::
isSecure, isWebKit, isOpera, isChrome, isSafari, isSafari3, isSafari4, isIE, isIE7, isIE8, isIE6, isGecko, isGecko3, isGecko2, isFirefox, isFirefox1, isFirefox2, isFirefox3, isWindows, isMac, isLinux, isSafariOnMac, isSafariOnWin, isGeckoOnMac, isGeckoOnLinux, isGeckoOnWin, isFirefoxOnMac, isFirefoxOnLinux, isFirefoxOnWin, isOperaOnMac, isOperaOnLinux, isOperaOnWin, isChromeOnMac, isChromeOnLinux, isChromeOnWin
For more information see interfaces.py module.
4. Tips
you can use detector conditions for kss and javascript resources also
you can use detector in templates to render different (X)HTML depending on browser/platform for example::
<tal:block define="detector nocall:context/browser-detector"> <tal:firefox condition="detector/isFirefox"> HERE COMES THE CODE FOR FIREFOX </tal:firefox> <tal:ie condition="detector/isIE"> HERE COMES THE CODE FOR IE </tal:ie> </tal:block>
Additionally you can display browser detection information in the browser detector portlet. Go to portlets management page (@@manage-portlets) and add new portlet “Browser Detector”. Portlet also has a link (in the footer) to browser view displaying results of each detection methods.
Copyright and Credits
collective.browserdetector is licensed under the GPL. See LICENSE.txt for details.
Author: Lukas Zdych.
Homepage: DMS4U.
Developed for NEXTUP.
Changelog
1.1.2 - (2009-08-20)
fixed broken package by missing manifest file [lzdych]
1.1 - (2009-07-08)
removed content providers and editable border from the detection view [lzdych]
fixed mistate in the README example using detector in templates [lzdych]
added explicit condition attributes related to Firefox browser [lzdych]
added firefox related stylesheet templates [lzdych]
1.0 - (2009-06-16)
Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for collective.browserdetector-1.1.2.zip
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52f31ee3f9a66190f9b1b3727475fa1fc6b1613d3abb2f9539fbdfd9377ff20c |
|
MD5 | 28f03615145f41b648b9d63534f4bf5f |
|
BLAKE2b-256 | fbd84da92bf95f2560371e9cacfee73728cd501956e33f6b4132a0b34140dbd3 |