Copied to clipboard

Flag this post as spam?

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


  • crono 58 posts 129 karma points
    Apr 22, 2015 @ 11:40
    crono
    0

    Refresh backend node using a custom datatype

    Hello,

    I've searched through the forum, and similar threads have popped up, but they are either for v4.x or have no replies - I'm looking for a v7.x solution.

    Let me describe our scenario:

    • We are rendering out images, from html, for nodes that are part of our newsletter (to get around styling issues in various email clients).

    • Nodes that have renderOutput properties show a Renderer tab that contains a preview of the images and a button to regenerate them.

    • The renderOutputs and the button to regenerate the images are each their own property.

    • The images are initially created when a node is saved and published for the first time, and only gets rerendered if the Regenerate Images button is clicked.

    Here's my 'problem':

    When I save and publish a node, each renderOutput property is updated with the new image path. But I'm missing a step when I click the Regenerate Images button - the renderOutput values are not visibly updated until I refresh the page.

    This is what the Regenerate Images button calls in the controller:

     public void RefreshHtmlPreview(int nodeId)
     {
         // Get content service
         var cs = UmbracoContext.Current.Application.Services.ContentService;
    
         // Get node as IContent
         IContent node = cs.GetById(nodeId);
    
         // Render html preview - same method is called in the Saving event
         RenderHtmlPreview(node);
    
         // Save and publish, but do not raise events to avoid rendering twice
         cs.SaveAndPublishWithStatus(node, 0, false);            
     }
    

    I tried adding umbraco.library.RefreshContent(); but it had no effect.

    How does Umbraco handle it on save and publish?

    Thanks in advance :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies