eZ Community » Forums » Developer » Change object content class?
expandshrink

Change object content class?

Change object content class?

Tuesday 02 January 2007 2:22:25 pm - 16 replies

Hi

Is it possible to change object created with one content class to object with different content class?

Let's say from object user(user class) to user( custom user class).

Best regards,
Sinisa

Tuesday 02 January 2007 3:30:01 pm

I've encountered this desire before.

If I was to do it again I might write a script to do this quickly.

If the customer is paying write a module blunk.gif Emoticon

//kracker

Tuesday 02 January 2007 3:37:37 pm

Hi

Hmm but do you have any suggestions how to do that?

Or by dooing SQL UPDATE in MySQL tables?

Some nice script would be the best solution!happy.gif Emoticon
Anyone with such script?

S.

Modified on Tuesday 02 January 2007 5:19:06 pm by Siniša Šehović

Thursday 04 January 2007 2:09:52 pm

I would suggest a script that extracts the information from one object and creates a new object based on this information. This seems to me the easiest and cleanest approach. The downside is of course that all objects get new ID's. But if this is a problem, you might have to tinker with the database itself.

Saturday 13 January 2007 7:33:30 am

Stay tuned, I'll try to post my contribution this afternoon.

Saturday 13 January 2007 8:40:38 am

Hi Kristof, ez guruhappy.gif Emoticon

Big thanx!

Best regards,
S.

Sunday 14 January 2007 11:42:26 pm

Hi guys,

I'm also working on extension which will allow to change object content class.
Unfortunately more code I have - more things I see still to do.

I can't promise any date, but I hope to post my contribution in 2-3 days.

Tuesday 16 January 2007 7:42:29 pm

My contribution in its current state is now available at http://ez.no/community/contribs/applications/extract_object_part (sorry for the delay).

Bartek, maybe we can join forces?

Tuesday 16 January 2007 8:41:25 pm

Hi Kristof

Thanks for the proposition happy.gif Emoticon In fact my extension is a little bit more advenced and it works in admin. Function can be called from context menu and for example it allows for manual attributes mapping between the same datatypes of both classes.
Right now I'm only facing problem with support for ezuser datatype (like you) and probably support for ezidentifier will be also omnited.

I would like finally to have my first own contribution on ez.no, so I'm sorry but I prefer to finish my extension. Of course we can exchange expirience happy.gif Emoticon

Tuesday 16 January 2007 8:59:38 pm

Hi,

(I haven't researched much).

Both your solutions seem to recreate new objects. Would it be possible to keep the same object but change the attributes id (to transfer each attribute) and class id (for the object) directly instead ?

Otherwise, is it possible with one of your contrib to transform a folder into an article or the other way around ? (most of my clients don't get the difference anyway).

Another related question, about changing the type of one attribute. Say that I want to transform one attribute from date to date time (or birthday or...). Would it be possible ?

Thanks for your contribution(s)

X+

Wednesday 17 January 2007 1:35:31 am

Finally posted initial release: http://ez.no/community/contribs/applications/object_content_class_change

Wednesday 17 January 2007 8:07:10 am

@Xavier

Both your solutions seem to recreate new objects. Would it be possible to keep the same object but change the attributes id (to transfer each attribute) and class id (for the object) directly instead ?

It should be possible with some hocus pocus happy.gif Emoticon I think it would be easy to add this to Bartek's extension, since it allows to do the mapping of different attributes manually. In my extension the attribute identifiers need to match.

The initial goal of my script was to extract certain portions of an object to another object, because the initial content class design wasn't right and one class had to be split up into two (and its existing content object instances too).

Another related question, about changing the type of one attribute. Say that I want to transform one attribute from date to date time (or birthday or...). Would it be possible ?

You can use the datatypes extension for that. Still need to commit some new stuff though. If you want I can help you with a plugin for specific datatypes.

@ Bartek
Adding support for ezuser is not that difficult, I know how to do it but I didn't have the time yet to write it.

In fact my extension is a little bit more advenced

I like your extension blunk.gif Emoticon But both extensions have their strengths and their weaknesses, it just depends on what you need them for.

For those who would like to test Bartek's extension: just enable it and start with /changeclass/select_class/[node_id]

Modified on Wednesday 17 January 2007 8:41:32 am by Kristof Coomans

Monday 22 January 2007 11:44:24 am

I assume what we are discussing here is a change from one class to another class with exactly the same attributes.
This is very usefull.
Another wish: is it possible to change datatype for an attribute. E.g you have an attribute of the datatype text which you want to chenge into datatype xml field (and keep all the content) ?

Monday 22 January 2007 12:54:09 pm

See Kristof reply at this question a few days ago:

You can use the datatypes extension for that. Still need to commit some new stuff though. If you want I can help you with a plugin for specific datatypes.

X+

Thursday 01 February 2007 11:15:58 pm

Hello

After some time I managed to upload new version of my contibution. Now it's possible to change content class of existing object without making of copy. Script creates all needed new attributes, for all object's versions. All data will stay if datatypes matches between classes.

In next week I will try to add possiblity to match attributes between different datatypes, in case if it's possible to easy transfer data. For example change Text line attribute to Text block or XML block.

I hope that someone will find my contribution useful blunk.gif Emoticon

Thursday 01 February 2007 11:28:59 pm

Sounds great !

Could you put it on pubsvn ? not that I think it will the code soon, but blunk.gif Emoticon

X+

Friday 02 February 2007 6:51:33 am

An I really wanted to thank Bartek for his prompt and unique contribution. Well done and thank you!

//kracker
<i>Stand out, Contribute!</i>

<i>Philip Glass - Einstein on the beach - 07 - knee play 3</i>

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from