Copied to clipboard

Flag this post as spam?

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


  • Gianni 10 posts 80 karma points
    Sep 06, 2021 @ 12:46
    Gianni
    0

    "Save and preview" shows only published content

    Hi there, I'm having an issue with the "Save and preview" feature. As the documentation says:

    The Save and preview button allows you to save your changes and preview it before publishing the changes to the live site. The Preview feature shows you how the page will look once it is published. This Save and preview feature only saves your page and does not publish your contents to the live site.

    I'm trying to add a simple text "ABC" inside a RTE of my page's grid content and I expect to see it when I click on "Save and preview" button, but no. Until I publish the content I'm not able to see this "ABC" text on preview page.

    Am I missing something? Maybe could be a wrong configuration?

    Thanks in advantage.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Sep 13, 2021 @ 12:14
    Alex Skrypnyk
    0

    Hi Gianni

    Can you check the template code? Maybe there is some kind of caching so the content is not showing.

    Preview uses the template to render the content

    Thanks, Alex

  • Gianni 10 posts 80 karma points
    Sep 14, 2021 @ 08:26
    Gianni
    0

    Thanks Alex, as you can see the template is quite simple:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Article>
    @using ContentModels = Umbraco.Web.PublishedModels;
    @{
        Layout = "Master.cshtml";
    }
    
    @functions {
        public static bool UserCanViewPage(bool memberIsSpecialist, bool pageIsForSpecialists)
        {
            return (!pageIsForSpecialists || (memberIsSpecialist && pageIsForSpecialists));
        }
    }
    
    @{
        bool memberIsSpecialist = false;
        bool userCanViewThisPage = true;
    
        var currentMember = Members.GetCurrentMember();
        if (currentMember != null) {
            memberIsSpecialist = (bool)currentMember.GetProperty("memberIsSpecialist").Value();
            userCanViewThisPage = UserCanViewPage(memberIsSpecialist, Model.PageIsForSpecialists);
        }
    }
    
    @if (userCanViewThisPage)
    {
        <div class="container">
    
            <div class="border-bottom d-flex justify-content-between">
                <h1>@Model.PageTitle</h1>
            </div>
    
            @if (!String.IsNullOrEmpty(Model.PageDescription)) 
            {
                <p class="text-mini pt-2">@Model.PageDescription</p>
            }
    
            @Html.GetGridHtml(Model, "pageContent")
        </div>
    }
    else 
    {
        @Html.Partial("NotAuthorized")
    }
    

    This template has only this peculiarity: to show the page the member must be logged and have a "true" flag for IsSpecialist property. Apart this, it shows values from Model (title, content and description), nothing so advanced.

    And no, there isn't cache in the Master template.

    The SignalR hub is working, the page is refreshing every time I made a modify from Umbraco panel, but the content is always the same :(

  • Joe Harvey 34 posts 174 karma points
    Sep 21, 2021 @ 14:54
    Joe Harvey
    0

    I am also seeing this on an Umbraco 8.11.1 install (a live client site) where everything seems to work as expected with the 'save and publish' button, except that it seems to just show the published version of the page.

    In my case, I am updating content in a 'pageTitle' (textstring editor) and 'content' (RTE editor) in the back-office, then clicking 'save and preview'. I get a new tab, URL of '/umbraco/preview/?id=[mypageid]' with the preview mode bar at the botto, but none of my recent changes shown (same is true if I manually 'Save' first, then 'save and preview'.

    I have various caching methods set up on this site, including things stored in runtime cache and the use of cached partials, but having reviewed my fairly simple template hierarchy for this basic content page (Master.cshtml > General.cshtml, with an @RenderBody() call) I can see no caching in play for these two simple properties on my content page.

    Any ideas how ton try and debug what is going on further?

  • Gianni 10 posts 80 karma points
    Sep 22, 2021 @ 11:33
    Gianni
    0

    Exactly, Joe.

    And still I don't understand why it happened. Still investigating the issue.

  • Gianni 10 posts 80 karma points
    Sep 23, 2021 @ 07:46
    Gianni
    0

    I finally discover the reason of my issue. In that installation of Umbraco I have a custom IdentityProvider (using Umbraco.Identity package).

    I found out that removing the custom identity at startup, the site started to preview my contents correctly.

    This solve my issue:

    app
                .UseUmbracoBackOfficeCookieAuthentication(UmbracoContextAccessor, RuntimeState, Services.UserService, GlobalSettings, UmbracoSettings.Security, PipelineStage.Authenticate)
                .UseUmbracoBackOfficeExternalCookieAuthentication(UmbracoContextAccessor, RuntimeState, GlobalSettings, PipelineStage.Authenticate)
                // TODO: this would be considered a breaking change but this must come after all authentication so should be moved within ConfigureMiddleware
                .UseUmbracoPreviewAuthentication(UmbracoContextAccessor, RuntimeState, GlobalSettings, UmbracoSettings.Security, PipelineStage.Authorize);
    

    Found this solution here:

    https://our.umbraco.com/forum/using-umbraco-and-getting-started/103456-page-preview-broken-when-using-umbraco-identity

  • Joe Harvey 34 posts 174 karma points
    Sep 29, 2021 @ 14:33
    Joe Harvey
    0

    Thanks for the update Gianni.

    I have taken a look at the linked solution and code snippet above, but I can't figure out where this snippet is supposed to be added or amended?

    Can you point me in the right direction please?

  • Gianni 10 posts 80 karma points
    Oct 21, 2021 @ 14:35
    Gianni
    0

    Hi Joe, as I told, I integrated a custom Auth provider and I added that code snippet in my OwinStartup custom class, inside App_Start folder, in the ConfigureUmbracoAuthentication method:

    protected override void ConfigureUmbracoAuthentication(IAppBuilder app)
    
  • Nidhi 32 posts 154 karma points
    Jul 16, 2023 @ 22:21
    Nidhi
    0

    Hi

    We are having issues with Save and Preview nested property type content for websites with Umbraco version 8.16.0. The steps include

    Adding content to any nested property for example Rich Text element/block and try to Save and preview and not publish. When we try seeing the change in the preview mode its fine but it also gets published on the main site. we don't want it to get published unless we press publish button. This is happening for nested content type with version 8.16.0.

    We have no custom Identity provider.

    Is there any solution to this?

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft