[Zope-PTK] New news class?

H.A. greyfolk@usa.net
Tue, 11 Apr 2000 21:23:52 -0700


On Wed, Apr 12, 2000 at 02:19:28AM +0200, Kusper Krisztian wrote:
> Hi!
> 
> So, i know that I'm totally lamer:-), but i have to ask the question:
> How can I create a new type of News Item, which has (for exampe) the
> oppurtunity to have picture in the description? I think it can be solved
> by table with place for the news and the picture, but it is a little bit
> complicated...
> 
Hi,

I think one clear cut way to do this is just to inherit the NewsItem class,
remove all parent's attributes, and add a new one to keep the image, redefine
the index_html and make a method to upload the image either through the
wizard or a class interface. And register the instantiation method to the
Portal.

The other way is using ZClass. I do most development using ZClasses (there's
a Howto somewhere on the zope site). Just create a product and inherit the 
NewsItem when you create the ZClass. Then create the wizard in the Portal
Wizards dir and in the property tab, action field, add a method defined in
the Portal folder to instantiate the ZClass. Put this code to the method:

<dtml-with "manage_addProduct['ZClass']">
 <dtml-call "ZClass_add(_.None, _, NoRedir=1)">
 <dtml-call "RESPONSE.redirect(URL1+'/portal_contents')">
</dtml-with>

where ZClass is the class name. In the ZClass_add, disable the code at the
bottom that redirect the URL to the management window. All these action
methods will eventually clutter my Portal folder, so I think the wizard
should get smarter and know what product/class to instantiate and use one
action method with the class name as parameter to do instantiation. For the
moment my folder is relatively clean compared to my desk, so I'll just
wait and maybe somebody will implement such thing 8-).

Regards,
Hendra