How to permanently delete IPublishedContent dynamically?
I'm creating new nodes (IContent), saving and publishing.
Then I'm executing the same script, checking the content (IPublishedContent) exists and deleting IContent using IPublishedContent Id.
Then checking if IPublishedContent exists - it exists - while IContent doesn't exist any more.
umbraco.config is not getting updated (the nodes still exist).
How to permanently delete IPublishedContent dynamically?
IPublishedContent existingContent = rootNode.Children.FirstOrDefault(i => i.DocumentTypeAlias == "MyAlias" && i.GetPropertyValue("propertyId").ToString() == item.PropertyId.ToString());
IContent content;
string name = item.Title;
if (existingContent != null) // after deleteing the IContent the next time I run the script the existingContent is not null and picks up the content which does not exist anymore
{
content = _contentService.GetById(existingContent.Id); // second run content is empty while existingContent still exists
// delete content - only second run (first run Delete line is commented out
if (content != null)
{
_contentService.Delete(content); // here content getting deleted
}
}
...
var createResponse = _contentService.SaveAndPublishWithStatus(content);
I don't want to republish all content, I want to find the content by IPublishedContent id.
So I can update it or delete it.
Currently I can find IPublishedContent but if I want to find IContent by its Id it's null and I need to create another content and publish which ends up in duplicating the content.
And in the back office old content (which I already deleted but still exists as IPublishedContent) and newly added content reappears.
foreach(IPublishedContent published in rootNode.Children)
{
// published exists
IContent cont = _contentService.GetById(published.Id);
// cont still doesn't exist so I cannot unpublish it
if(cont != null)
{
_contentService.UnPublish(cont);
}
}
Cont still doesn't exist so I cannot unpublish it.
Although some content exists but then
_contentService.UnPublish(cont);
does nothing - the content stays published and displays in bakc office.
How to permanently delete IPublishedContent dynamically?
I'm creating new nodes (IContent), saving and publishing.
Then I'm executing the same script, checking the content (IPublishedContent) exists and deleting IContent using IPublishedContent Id.
Then checking if IPublishedContent exists - it exists - while IContent doesn't exist any more.
umbraco.config is not getting updated (the nodes still exist).
How to permanently delete IPublishedContent dynamically?
Hi Manila
I think you can republish content with this method:
Thanks
Alex
I don't want to republish all content, I want to find the content by IPublishedContent id.
So I can update it or delete it.
Currently I can find IPublishedContent but if I want to find IContent by its Id it's null and I need to create another content and publish which ends up in duplicating the content.
And in the back office old content (which I already deleted but still exists as IPublishedContent) and newly added content reappears.
Another solution is to unpublish node before deletion:
What if the content has been already been deleted but still exists as IPublishedContent?
I need to remove IPublishedContent permanently - wherever it resides
If the content has been deleted, you have to republish all site once.
I can't republish all site because I cannot publish other items which should remain unpublished.
Can I republish only selected node's children?
Manila, republish is republishing only existing published content, content items that have been removed will not be published during republish.
Alex
Ok
I did
then
Cont still doesn't exist so I cannot unpublish it.
Although some content exists but then
_contentService.UnPublish(cont);
does nothing - the content stays published and displays in bakc office.
You can see published and unpublished content in the back office.
The content I've just unpublished appears to be published and I've just said I can still get it as
IPublishedContent
- it means it remains published.The problem remains - even though the content is published I cannot get it using
which returns null.
Manila, if _contentService.GetById(existingpublishedcontent.Id); returns null - it means that in database no this content anymore.
If you still see it on the front end as "IPublishedContent" then you have this content only in xml, republish all should fix it.
Or try to remove umbraco.config
Thanks
Alex
Hi Manila
Did you solve the issue? Share with our community please.
THanks,
Alex
Thanks.
That's what I needed to know!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.