#178: Return to using getIcon for content type icons
Aka. as "the un-PLIP", this proposal advocates changing back to the earlier approach used for content type icons in Plone.
- Proposed by
- Michael Davis
- Seconded by
- Alexander Limi
- Proposal type
- Architecture
- Assigned to release
- Repository branch
- plip178-back-to-icons-as-images
- State
- completed
Motivation
For Plone 2.1, we switched to using CSS to display the content type images. This gave us some flexibility, but the main reason for doing so was to keep stuff outside of the portal catalog.
It has later been shown to me that our original assumptions of how this would affect the catalog were false (I thought it stored the icon itself, whereas it would only store the path to the image used as a string - a trivial addition).
The following problems exist with the current CSS-based implementation in 2.1/2.5:
- It bloats the CSS unnecessarily. In 2.1/2.5, this increased the initial page download weight of the average Plone page a lot, and although we have found ways of decreasing this, it still adds a significant amount of CSS.
- Browser bugs (Internet Explorer) requires us to us more CSS and twice the amound of markup to access the icons (we essentially need a "dead" wrapper class around the original one to avoid flickering on hover in IE6). This makes a lot of the initial attraction to this approach irrelevant.
- It's not possible to support different icons for the same content type (example: checked icon for a completed task, unchecked for an open task) with the CSS-based approach unless you do workarounds.
- Less magic - the current CSS icon approach is similar to the logo approach, where the logo is invoked via CSS in an obscure (for most people) manner. The element of least surprise is important for our integrators/customizer audience. It also removes the need to create dynamically generated CSS for this.
Proposal
This PLIP is in direct contrast to PLIP 132 - which advocates extending the current approach to work around the current deficiencies. We believe returning to the original approach is a lot more sane, and makes everything less complex.
- Remove all CSS definitions for icons for portal_types.
- Restore HTML generated icons based on getIcon method in portal_catalog (folder listings and navtree).
Implementation
When an object is cataloged within the portal, the getIcon method is called and indexed in portal_catalog with a string value in the form of: newsitem_icon.gif or portalName/newsitem_icon.gif.
Risks
Any site which has been customised to take advantage of CSS-generated icons would need to be re-customized.
This doesn't seem to be a common customization from casual observation (most people have no idea how the current approach even works in 2.1/2.5 ;), and no add-on products use the CSS-based type icons as far as we have observed.
Progress log
Done, except for a small migration step. I had to add getIconName as catalog metadata, as the existing getIcon stores the absolute ZODB path instead of just the icon file name. To prevent a restrictedTraverse call for each icon, I just added a small wrapper script. The existing getIcon metadata should probably be deleted, as it's unusable.
[fschulze]
Participants
Michael Davis
Alexander Limi
Florian Schulze

