Share » Forums » Developer » Change object content class?

Change object content class?

Change object content class?

Tuesday 02 January 2007 5:22:25 am - 16 replies

Author Message

kracker (the)

The Doctor

Tuesday 02 January 2007 6:30:01 am

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 ;)

//kracker

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Siniša Šehović

Tuesday 02 January 2007 6:37:37 am

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!:-)
Anyone with such script?

S.

---
If at first you don't succeed, look in the trash for the instructions.

Atle Pedersen

Thursday 04 January 2007 5:09:52 am

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.

Kristof Coomans

Friday 12 January 2007 10:33:30 pm

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

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Siniša Šehović

Friday 12 January 2007 11:40:38 pm

Hi Kristof, ez guru:-)

Big thanx!

Best regards,
S.

---
If at first you don't succeed, look in the trash for the instructions.

Bartek Modzelewski

Sunday 14 January 2007 2: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.

Baobaz
http://www.baobaz.com

Kristof Coomans

Tuesday 16 January 2007 10:42:29 am

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?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Bartek Modzelewski

Tuesday 16 January 2007 11:41:25 am

Hi Kristof

Thanks for the proposition :-) 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 :)

Baobaz
http://www.baobaz.com

Xavier Dutoit

Tuesday 16 January 2007 11:59:38 am

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+

http://www.sydesy.com

Bartek Modzelewski

Tuesday 16 January 2007 4:35:31 pm

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

Baobaz
http://www.baobaz.com

Kristof Coomans

Tuesday 16 January 2007 11:07:10 pm

@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 :-) 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 ;-) 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]

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Helle Andersen

Monday 22 January 2007 2: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) ?

Xavier Dutoit

Monday 22 January 2007 3:54:09 am

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+

http://www.sydesy.com

Bartek Modzelewski

Thursday 01 February 2007 2: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 ;)

Baobaz
http://www.baobaz.com

Xavier Dutoit

Thursday 01 February 2007 2:28:59 pm

Sounds great !

Could you put it on pubsvn ? not that I think it will the code soon, but ;)

X+

http://www.sydesy.com

kracker (the)

The Doctor

Thursday 01 February 2007 9:51:33 pm

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>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

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

36 542 Users on board!

Forums menu