update to 7.6.2/3 and core property value convertors, id to uid aka mediaPicker to mediaPicker2
So having to sort the stored Id on a mediaPicker once datatype updated to mediapicker2 property
RIght click publish all child nodes of root, doesn't udpate the old ids stored to uids. With several thousand news stories with a picked thumbnail individual save and publish wasn't an option..
So came up with a dirty one off update via a template.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using ContentModels = Umbraco.Web.PublishedContentModels;
@{
Layout = null;
}
@{
var cs = ApplicationContext.Current.Services.ContentService;
var ms = ApplicationContext.Current.Services.MediaService;
var collection = cs.GetDescendants(cs.GetRootContent().First().Id);
foreach (var item in collection.Where(x => x.ContentType.Name == "Item Dated"))
{<ul>
<li>
<strong>@(item.Name) @("::") @(item.ContentType.Name)</strong>
<ul>
<li>@updatePropertyToUDI(item, "itemThumbnail")</li>
</ul>
</li>
</ul>
}
}
@helper updatePropertyToUDI(IContent item, string propAlias)
{
try
{
var cs = ApplicationContext.Current.Services.ContentService;
var ms = ApplicationContext.Current.Services.MediaService;
var existing = item.GetValue(propAlias);
@("["+existing+"]")
var thumb = item.GetValue<int>(propAlias);
if (thumb > 0)
{
var mThumb = ms.GetById(thumb);
@(" --> umb://media/" + mThumb.Key)
item.SetValue(propAlias, "umb://media/" + mThumb.Key);
cs.Publish(item);
}
}
catch (Exception e)
{
@(e.Message)
}
}
However, this doesn't fit for when a page is saved, eg edited and not ready for publish... is there any way to republish the published version of a content node?
update to 7.6.2/3 and core property value convertors, id to uid aka mediaPicker to mediaPicker2
So having to sort the stored Id on a mediaPicker once datatype updated to mediapicker2 property
RIght click publish all child nodes of root, doesn't udpate the old ids stored to uids. With several thousand news stories with a picked thumbnail individual save and publish wasn't an option..
So came up with a dirty one off update via a template.
However, this doesn't fit for when a page is saved, eg edited and not ready for publish... is there any way to republish the published version of a content node?
Thought I might be able to do this with the
var PubVersionOfItem = cs.GetPublishedVersion(item); and published that IContent Item...
But whilst this republishes the previously published version.. it also then overwrites any saved but not published changes to the node.
Perfect, It Works fine.
Thanks you @mistyn8
is working on a reply...