Forums / Developer / The best way to customise an attribute

The best way to customise an attribute

Author Message

Tristan Koen

Tuesday 10 June 2003 5:46:48 am

I need to customise the 'author' attribute. In its default form, it only provides entries for the authors' name and email address. I need to extend the functionality to include a small portrait and a short biography.

I could customise the code in kernel/classes/datatypes/ezauthor/ezauthorXXXX.php but I am worried about sacrificing application portability - i.e. what happens when say ez4.0 comes out?

Any advice from anyone on the best way to do this?

Paul Borgermans

Tuesday 10 June 2003 6:46:52 am

Tristan,

You should not change base dataypes to avoid future compatibility problems. Best to clone and extend this datatype to suit your needs.

However, can't you simply use extra attributes in the content class where you want to use the author field? Or do you need the multiple entry feature of that datatype?

In that case, create one or more "related objects" or even child objects based on a new "author class" which contains just the atttributes you need (look how its done in the admin site)? In that way you may easily add this to your templates where a user can choose from a pre-fetched list of authors or create a new one if the author does not exist yet. This also adds the benifit that that you can "manage" authors on your site and create other features in the future with the author objects.

Not done myself, but in priciple it should be possible without creating a new dataype.

eZ publish is a little bit like perl, "there is more than one way to do it". In practice: quite some things that previously needed php coding can be done in and with ezp3 templates.

Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans