Thank you very much for your response! I wasn't aware of the difference between IPublichedContent and IContent so thank you for helping me out in that regard.
However, I can get it to change for a single page. But how can I loop through every page of a specific documentType?
//Mike
EDIT: I found a way, probably not the best solution but it worked:
@{
Layout = "Master.cshtml";
IContentService contentService = ApplicationContext.Services.ContentService;
var contentItem = ApplicationContext.Services.ContentService.GetById(1064);
foreach (var item in contentItem.Descendants())
{
if (item.HasProperty("ikkeTilSalg"))
{
item.SetValue("ikkeTilSalg", "1");
ApplicationContext.Services.ContentService.SaveAndPublish(item);
}
}
}
Thank you Alex, for providing useful links and info's!
.setValue for IPublishedContent?
Hi guys,
I'm trying to set all bools for a specific document type to false but I can't seem to figure out how.
Using the code below I can retrieve all pages with the "notForSale" set to false. However I would like to change that value to true, but how?
I can't use .setValue("notForAle", "1") on IPublishedContent
Hi MBE
IPublishedContent is only for reading data. For all changes to the database use IContent and ContentService, read about content service - https://our.umbraco.com/documentation/Reference/Management/Services/ContentService/
Thanks,
Alex
Also, do not use
.Descendants()
it's a very slow methodSo your code will look like:
Hi Alex,
Thank you very much for your response! I wasn't aware of the difference between IPublichedContent and IContent so thank you for helping me out in that regard.
However, I can get it to change for a single page. But how can I loop through every page of a specific documentType?
//Mike
EDIT: I found a way, probably not the best solution but it worked:
Thank you Alex, for providing useful links and info's!
is working on a reply...