Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andreas Pfanner 196 posts 314 karma points
    Jan 12, 2011 @ 15:30
    Andreas Pfanner
    0

    Relate copied items to original

    Hello,

    is it possible to force editors to select the "Relate copied items to original" checkbox when they copy documents?
    I would require that for multilingual page switcher.. Can it be configured somewhere?

     

    Best Regards

    Andreas

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 12, 2011 @ 19:40
    Jan Skovgaard
    0

    Hi Andreas

    I'm not sure that it's possible to hook into the event that triggers the content menu to show. I think this may require you to compile your own version of Umbraco perhaps.

    Why do you need to make sure that the "relate copied items to original" checkbox is checked?

    /Jan

  • Andreas Pfanner 196 posts 314 karma points
    Jan 12, 2011 @ 22:08
    Andreas Pfanner
    0

    Hello Jan,

    thanks for your reply.

    I have a multilingual site with the ability to switch the language on every page and getting directly to the right page in the chosen language (not just to the home page). So if you are on the english products page and click the german flag, you get directly to the german products page. To get this information in the language switcher macro (to generate the links) I use the relation data. Therefor I would like to assure that if an editor copies new content, the relationship is created.

    Best Regards

    Andreas

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 12, 2011 @ 22:13
    Jan Skovgaard
    0

    Hi Andreas

    That sounds like a neat solution you have made there - I got a little inspired for the next multi-language site when I get the task of making one again.

    Unfortunately I have not come across a solution to your request. But maybe some others in here know how it can be done.

    Cheers

    /Jan

  • Andreas Pfanner 196 posts 314 karma points
    Jan 12, 2011 @ 22:36
    Andreas Pfanner
    0

    Hi Jan,

    as I figured out, using the built-in document relationship feature on copying, its pretty easy to implement such a precise language switching. I only have to provide 2 languages for the site, it will be a little more complex with more languages, but I think it would also be possible, and its probably the best way to achieve that today with Umbraco...

    Best Regards

    Andreas

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 12, 2011 @ 22:43
    Tom Fulton
    1

    I haven't tried this, but maybe you could use an event handler that triggers on the Copy event, and just create the relation yourself (regardless of the checkbox) via API?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 12, 2011 @ 22:55
    Jan Skovgaard
    0

    Hi again

    Hmm, yes I think Tom is on to something here...If you need to set the relationship using the API I guess it should really just be a matter of hooking into the create event of a node and do the relation stuff?

    In case you have not seen it there is a overview of the events here: http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/overview-of-all-events

    /Jan

  • Andreas Pfanner 196 posts 314 karma points
    Jan 12, 2011 @ 23:04
    Andreas Pfanner
    0

    Alright, thank you very much!

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 13, 2011 @ 14:20
    Tom Fulton
    2

    FYI, some code to get you started if you need it - to create a relation progamatically.

    One thing I'm not sure about is if the Copy event passes both the original and new node ID's - I think it didn't in the past but it might have been added/fixed in 4.6

    using umbraco.cms.businesslogic.relation;
    RelationType relationType = RelationType.GetByAlias("relationTypeAliasHere");
    Relation.MakeNew(masterProd.Id, childProd.Id, relationType, "comment here");

    Hendy's Relation Types Dashboard project also makes it easy to create/manage your relation types.  His blog also has some good info on getting started with relations API.

  • Andreas Pfanner 196 posts 314 karma points
    Jan 13, 2011 @ 14:49
    Andreas Pfanner
    0

    Thats great to know! Thank you!

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jan 13, 2011 @ 15:03
    Hendy Racher
    1

    Hi,

    FYI, if you have uComponents installed, there are some helper methods to extend the RelationType object to be able to retrieve the associated ObjectType GUIDs, and to ensure that any relations created don't conflict with these specified types, as well as a couple of other methods.

    HTH,

    Hendy

  • Andreas Pfanner 196 posts 314 karma points
    Jan 13, 2011 @ 15:53
    Andreas Pfanner
    0

    Thanks, very helpful!

Please Sign in or register to post replies

Write your reply to:

Draft