London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Change ParentLink on Published event

Vote:
 

Hi,

Is it possible in any way to change the ParentLink of a page while the page is published?
The ParentLink property (args.Page.ParentLink) seems to be read only.

#90636
Sep 15, 2014 12:57
Vote:
 

Via code?

In the EPiServer GUI you could move the page /w drag-n-drop to another parent or use cut-n-paste.

#90641
Sep 15, 2014 13:20
Vote:
 

Via code

#90650
Sep 15, 2014 13:56
Vote:
 

Found a solution. Call DataFactory.Instance.Move when page is beeing published.

#90654
Sep 15, 2014 14:21
Vote:
 

Hi Anders,

Your server code is a best way, I just want to introduce an alternative way using client side ;)

var contentDataStore = registry.get("epi.cms.contentdata"),
                    contentStructureStore = registry.get("epi.cms.content.light");
                //--------------------------------------------------------------------------------------
                // Listen change content status actions
                //--------------------------------------------------------------------------------------
                aspect.around(contentDataStore, "executeMethod", function (originalMethod) {
                    return function (method, id, data, options) {
                        return when(originalMethod.apply(contentDataStore, arguments), function (result) {

                            if (result && result.success && epi.areEqual(method, "ChangeStatus")) {
                                var saveAction = ContentActionSupport.saveAction,
                                    action = ContentActionSupport.action,
                                    currentAction = data && data.action;
                                switch (currentAction) {
                                    case action.Reject:
                                        // TODO: Do whatever you want
                                        break;
                                    case action.Publish:
                                        // Move the published page to new destination
                                        when(contentStructureStore.move(id, {targetId: publishedPageContainer /*Replace with your real content reference*/ }), function(moveContentResult) {
                                            topic.publish("/epi/cms/contentdata/childrenchanged", publishedPageContainer);
                                        });
                                        break;
                                    case action.CheckIn:
                                        // TODO: Do whatever you want
                                        break;
                                    case saveAction.CheckIn | saveAction.DelayedPublish | saveAction.ForceCurrentVersion:
                                        // TODO: Do whatever you want
                                        break;
                                    default:
                                        break;
                                }
                            }

                            return result;
                        })
                    }
                })

Happy coding!

Ha Bui

#90666
Sep 16, 2014 5:08
Vote:
 

Thanks Habu for your comments!

/Anders

#90671
Sep 16, 2014 7:44
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.