Hello Everyone,
Good Day.
I got all the content by culture but I can't get the update date by culture. There is no difference between the two. Is there any way to get the update date and updated by for every culture? Below is my code of getting all the content by culture.
var getAllContent = new List<GetAllContentByCulture>();
foreach (var clture in Umbraco.ContentAtRoot().First().Cultures)
{
var getContentProperties = new List<ContentProperty>();
// This is how the culture is set for the context we are in
_variationContextAccessor.VariationContext = new VariationContext(clture.Key);
var allPublishedContent = new List<IPublishedContent>();
foreach (var publishedContentRoot in Umbraco.ContentAtRoot())
{
allPublishedContent.AddRange(publishedContentRoot.DescendantsOrSelf());
}
foreach (var c in allPublishedContent)
{
if (c.Name == "Settings" || c.Name == "General" || c.Name == "Theme")
{
continue;
}
getContentProperties.Add(new ContentProperty
{
id = c.Id,
pagename = c.Name,
lasteditdate = c.UpdateDate.ToString("MMM-dd-yyyy h:mm tt"),
editedby = c.WriterName.ToString(),
url = c.Url.ToString()
});
}
getAllContent.Add(new GetAllContentByCulture
{
language = clture.Key,
contentProperties = getContentProperties
});
}
Get Update date and edited by by culture.
Hello Everyone, Good Day. I got all the content by culture but I can't get the update date by culture. There is no difference between the two. Is there any way to get the update date and updated by for every culture? Below is my code of getting all the content by culture.
Hi,
You can get this data by using the ContentService.
This gets the latest date when the item was updated. You can also use GetPublishDate to get the latest date the culture was published.
-Joep
Ah when writing the previous answer, I found an other extension. In your code you can use
c.CultureDate(clture.Key)
to get the latest published date.Hello Joep,
Thanks! I got it correct by doing this c.Cultures[clture.Key].Date.
Regards, Ivan
is working on a reply...