[Zope-PTK] Replacing Icons for standard content types

Tres Seaver tseaver@digicool.com
Wed, 21 Feb 2001 18:39:52 -0500


Lucas Hofman wrote:
> 
> What would be the 'best' way to change the icons for the standard
> content types like document, link, file  etc.?
> 
> As far as I can see are these defined by the call to
> registerportalContent:
> registerPortalContent(News,
>                       constructors=(addNewsItem,),
>                       action='Wizards/NewsItem',
>                       icon="newsitem.gif",
>                       productGlobals=globals())
> 
> The link generated by
> <img src="&dtml-portal_url;/<dtml-var expr="obj.getIcon()">"
> evaluated to:
> <img
> src="http://tanya.oslo.seres.pgs.com:8080/seres/misc_/PTK/News%20Item"
> 
> Zope finds this in PTKDemo, and not in the custom skin directory.
> 
> How can I change the icon for 'News Item' without replacing newsitem.gif
> in PTKDemo? (which makes updating difficult). Do I have to make a new
> class just to change the Icon?
> 
> Any help is very welcome.

The content classes currently implement a 'getIcon' method (added
to allow Favorites to "borrow" the icon of the object they point to).
We could perhaps store the icon on the type object for the content
object, configured throught the 'portal_types' tool, instead of finding
it via the class attribute created during 'registerPortalContent'.

Until we make such a change, your best shot is to create a ZClass which
derives from the appropriate Python class, and map it onto your type
object.  See Dave Woolston's "ZClass content" tutorial at:

  http://cmf.zope.org/Members/davew/PortalStuff/PortalPollTutorial

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@digicool.com
Digital Creations     "Zope Dealers"       http://www.zope.org