Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi all,
I am doing something similar to http://our.umbraco.org/forum/developers/api-questions/7461-Moving-a-document-not-updating-Link-to-document where I am moving a node in the AfterPublish event to a different area of the tree.
Everything works well except the 'Link to document' and 'Alternative link' are not updating.
I've tried using umbraco.library.RefreshContent(); in the AfterPublish like so:
//Create the news itemUser author = User.GetUser(0);newsDoc.Move(newsMonth.Id);newsDoc.Publish(author);umbraco.library.UpdateDocumentCache(newsDoc.Id);umbraco.library.RefreshContent();
but this does not appear to work.
I've also tried this:
public ContentUpdateCache() { umbraco.content.AfterUpdateDocumentCache += new content.DocumentCacheEventHandler(Content_UpdateCache); } private void Content_UpdateCache(Document sender, DocumentCacheEventArgs e) { if (sender.ContentType.Alias == "XXX") { umbraco.library.RefreshContent(); } } }
But this doesn't work either
Any help greatfully recieved, I'm sure I'm missing something obvious...
thanks,
Steve
I think a simple document.Publish(new User(0)); before RefreshContent could well do the trick.
In the end what I had was more or less correct, I was doing this in the AfterPublish:
//Create the news itemUser author =User.GetUser(0);newsDoc.Move(newsMonth.Id);newsDoc.Publish(author);umbraco.library.UpdateDocumentCache(newsDoc.Id);umbraco.library.RefreshContent();
And this in the AfterUpdateDocumentCache
publicContentUpdateCache() { umbraco.content.AfterUpdateDocumentCache+=new content.DocumentCacheEventHandler(Content_UpdateCache); } privatevoidContent_UpdateCache(Document sender,DocumentCacheEventArgs e) { if(sender.ContentType.Alias=="XXX") { umbraco.library.RefreshContent(); } } }
This didn't seem to work, but then I deleted this line:
umbraco.library.UpdateDocumentCache(newsDoc.Id);
and it all seems to work, curious...
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Updating 'Link to document' after node moved in api
Hi all,
I am doing something similar to http://our.umbraco.org/forum/developers/api-questions/7461-Moving-a-document-not-updating-Link-to-document where I am moving a node in the AfterPublish event to a different area of the tree.
Everything works well except the 'Link to document' and 'Alternative link' are not updating.
I've tried using umbraco.library.RefreshContent(); in the AfterPublish like so:
but this does not appear to work.
I've also tried this:
But this doesn't work either
Any help greatfully recieved, I'm sure I'm missing something obvious...
thanks,
Steve
I think a simple document.Publish(new User(0)); before RefreshContent could well do the trick.
In the end what I had was more or less correct, I was doing this in the AfterPublish:
And this in the AfterUpdateDocumentCache
This didn't seem to work, but then I deleted this line:
and it all seems to work, curious...
is working on a reply...