A project I'm working on calls for functionality to create nodes beneath a target node, which may already contain child nodes, and to publish all of those children when the publish button is hit in the designer UI.
In order to accomplish this, I've subscribed to the BeforePublish event for the target node. When the event fires, I check the sender for children, then iterate over those children to 'publish' them.
Here's the delegate:
public static void Document_BeforePublish(Document Sender, PublishEventArgs E)
{
if (_targetContentTypes.Contains(Sender.ContentType.Alias))
{
foreach (var Child in Sender.Children)
{
Child.PublishWithResult(new User(0));
}
}
}
_targetContentTypes is simply a managed list of document which should exhibit this behavior.
My issue is that the documents appear to publish in the content editor (they turn solid), but the updated data doesn't appear on the site.
No sooner did I post this than I found the solution in another person's work. For some reason I can't delete this topic, so for those like me who are too lazy to read examples, use "umbraco.library.UpdateDocumentCache(Child.ID)".
Backend publishing not behaving as expected
A project I'm working on calls for functionality to create nodes beneath a target node, which may already contain child nodes, and to publish all of those children when the publish button is hit in the designer UI.
In order to accomplish this, I've subscribed to the BeforePublish event for the target node. When the event fires, I check the sender for children, then iterate over those children to 'publish' them.
Here's the delegate:
public static void Document_BeforePublish(Document Sender, PublishEventArgs E)
{
if (_targetContentTypes.Contains(Sender.ContentType.Alias))
{
foreach (var Child in Sender.Children)
{
Child.PublishWithResult(new User(0));
}
}
}
_targetContentTypes is simply a managed list of document which should exhibit this behavior.
My issue is that the documents appear to publish in the content editor (they turn solid), but the updated data doesn't appear on the site.
No sooner did I post this than I found the solution in another person's work. For some reason I can't delete this topic, so for those like me who are too lazy to read examples, use "umbraco.library.UpdateDocumentCache(Child.ID)".
is working on a reply...