Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am creating content using Umbraco API's Document service, which should be automatically saved in DateFolders (year, month, day). When I create the content manually it is automatically saved in DateFolders, but using API it doesn't work. Is there a way to make sure that it is saved there or at least some way to do it afterwards for all of them at once?
Thanks in advance.
p.s I have tried DateFolder and uDateFoldersy packages.
Could you post the code so we can see what might go wrong? When using the API it only works if you call UmbracoContext.Current.Application.Services.ContentService.Save(content) afterwards.
If you only want to use datafolders so you can have a date in the url you should read this blog: http://24days.in/umbraco/2014/urlprovider-and-contentfinder/. You can also add a date to a url programmatically.
Thanks for your reply. This is my code:
public string PostNews(string name, string postDate, string bodyText, int id, string source, int category)
// Get the Umbraco Content Service
var contentService = ApplicationContext.Current.Services.ContentService;
var news = contentService.CreateContent(
name, // the title of the news
id, // the parent id should be the id of the group node
"NewsPage", // the alias of the news list Document Type
// We need to update properties (product id, original name and the price)
// finally we need to save and publish it (which also saves the news!) - that's done via the Content Service
The datefolders are set to create a folders based on the postDate attribute, however, it doesn't. It does only when I click manually Save inside the Umbraco.
You need to do this after you save:
...contentService.Save(news);news = uDateFoldersy.DateFolderService.Instance.EnsureCorrectParentForPost(news, false);contentService.SaveAndPublishWithStatus(news);
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted