Forums / Developer / Variable number of class attributes

Variable number of class attributes

Author Message

Oliver Frommel

Wednesday 05 September 2007 6:02:05 am

Hi,

is it possible to create as class with a variable number of attributes?
Or, in another words, to encapsulate attribute types in a kind of array or
as a "linked list"?

For instance to have an article reference a number of URLs that is
unknown at the time of class creation. If it isn't possible at this time
it would be a great addition to eZ publish :)

Best
Oliver

Atle Pedersen

Wednesday 05 September 2007 6:18:31 am

Hi,

you cannot do this directly, but what you can do is having subnodes with objects containing the url information. Then you can have as many objects as you want.

An alternative method is using the object relations attribute to link to objects containing url information.

I would probably go for the first method since that means you don't have to edit the article in order to add more links.

Xavier Serna

Thursday 06 September 2007 6:36:20 am

Hi Olivier,

the fact is that for your case, is as simple as add an ezmatrix attribute to your class, you can define the required number of columns you want for each row (in your case, each url), for example one column for the website name and another one for the website url.
The rows are added at the time of the article editing, without limitation, so you can add as many rows as you need in each object.

hth!

--
Xavier Serna
eZ Publish Certified Developer
Departament de Software
Microblau S.L. - http://www.microblau.net
+34 937 466 205

Betsy Gamrat

Saturday 29 September 2007 6:45:21 pm

Hi,

<i>For instance to have an article reference a number of URLs that is
unknown at the time of class creation. If it isn't possible at this time
it would be a great addition to eZ publish :)</i>

This is an object relation list. :)

Betsy