Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tobias Pettersson 19 posts 112 karma points
    Apr 26, 2017 @ 11:58
    Tobias Pettersson
    0

    Issue getting created content from Node with Children and GetChildren.

    I have an application running Umbraco v7.5.11 where I, through a BeginUmbracoForm create a page under a certain Node.

    var contentService = Services.ContentService;
            var settingsPage = __settings.SettingsPageId?.MapToPage<SettingsPageContent>();
            var vacancyPage = settingsPage.VacancyListPageId?.MapToPage<VacancyFormPageContent>();
    
            var createdContent = contentService.CreateContent(viewModel.FormHeading, vacancyPage.Id, __settings.VacancyPageContentTypeName);
    
            createdContent.SetValue("heading", viewModel.FormHeading);
            createdContent.SetValue("mainBody", viewModel.FormText);
            createdContent.SetValue("companyName", viewModel.FormCompanyName);
            createdContent.SetValue("companyEmail", viewModel.FormContactEmailAdress);
            createdContent.SetValue("companyPhone", viewModel.FormContactPhone);
            createdContent.SetValue("vacancyCategory", viewModel.VacancyCategory);
    
            createdContent.ExpireDate = DateTime.Now.AddDays(60);
    
            var statuses = contentService.SaveAndPublishWithStatus(createdContent);
    

    My issue is: when I list these created pages in my view like so:

    @foreach (var vacancyPage in Model.VacancyPages)
            {
                <li class="c-list__item" data-category="@vacancyPage.VacancyCategory">
                    <div class="c-toggler c-toggler--align-left c-toggler--padding-bottom">
                        <i class="icon-thumb-tack c-toggler__icon c-toggler__icon--vacancy"></i>
                        <h2 class="c-toggler__heading">@( vacancyPage.CreateDate.ToString("yyyy/MM/dd") + " - " + Html.Raw(vacancyPage.Heading) )</h2>
                        <div class="c-list__sub-heading">@vacancyPage.CompanyName</div>
                        <a href="#" class="c-toggler__button"></a>
                        <div class="c-toggler__content c-list__preamble">
                            @vacancyPage.MainBody
                        </div>
                    </div>
                </li>
            }
    

    the list is empty even though I can see that my pages are published and saved in the umbraco backoffice.

    For some reason when I'm logged in and the UMB_UCONTEXT cookie is set the page is not published properly because when I manually go to the page and savepublish it it appears. And if I clear the cookie and reload same thing happens and the list is working as inteaded.

    I've done some experimenting about this and it seems that using the publish method or what ever method calling the publish method like SaveAndPublishWithStatus and so on does not publish content properly.

    I've tried updating the Xml cache manually after creating, I've tried republishing the entire site aswell but same result.

    When I call GetChildren from Services.ContentService the list is populated with all IContent objects, even those that are not shown, but those pages created while being logged in returns null. They are not properly published for some reason. They appear published but they arn't.

    Anyone else having this issue?

Please Sign in or register to post replies

Write your reply to:

Draft