Copied to clipboard

Flag this post as spam?

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


  • Kurt Moskjaer Andersen 40 posts 95 karma points
    Nov 23, 2016 @ 10:38
    Kurt Moskjaer Andersen
    0

    List sent newsletters on frontend

    Hi,

    It may have been asked before, but is it possible to make a list of the sent newsletters on the frontend?

    I'm aware, that there are some merge-fields and personalization, which cannot be rendered properly.

    Kind regards Kurt

  • Markus Johansson 1701 posts 4879 karma points c-trib
    Nov 23, 2016 @ 10:52
    Markus Johansson
    0

    Hi!

    You could keep your newsletters as content in the content sextionde - otherwise you would have to list sent letters from the Newsletter repository and render them from there.

    / m

  • Kurt Moskjaer Andersen 40 posts 95 karma points
    Nov 23, 2016 @ 10:55
    Kurt Moskjaer Andersen
    0

    Hi,

    At the moment we are not using it as content in the content section, but in the Newsletter Studio alone.

    Would you suggest, that we make a query directly in the database and list them from here?

    Kind regards Kurt

  • Markus Johansson 1701 posts 4879 karma points c-trib
    Nov 23, 2016 @ 15:37
    Markus Johansson
    100

    Hi!

    I'm well aware of that we need a better API for this, I would not recommend going to the db directlly - this would be my recommended solution at the moment (Works on Newsletter Studio 2+):

    @using NewsletterStudio.Core.Model
    @using NewsletterStudio.Infrastucture
    @using NewsletterStudio.Infrastucture.Services
    @using NewsletterStudio.Services.RenderTasks
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    @{
        // This will give you all the newsletters thats listed in the "Sent"-folder in the backoffice. This means that they are not older than 90 days.
        var listOfNewslettersLast90Days = new NewsletterService(GlobalFactory.Current.NewsletterRepository).GetSent();
    
        // This will give you all letters that has been successfully sent.
        var listOfAllSentNewsletters = NewsletterStudio.Infrastucture.GlobalFactory.Current.NewsletterRepository.GetByStatus(new int[] { NewsletterStatus.Completed});
    }
    @if (Request.QueryString["id"] == null)
    {
        <ul>
            @foreach (var item in listOfAllSentNewsletters)
            {
                <p>
                    <a href="/[email protected]">@item.Name</a>
                </p>
            }
        </ul>
    }
    else
    {
        var letter = GlobalFactory.Current.NewsletterRepository.GetById(Convert.ToInt32(Request.QueryString["id"]));
        RenderEngine renderEngine = new RenderEngine(letter);
    
        @Html.Raw(renderEngine.RenderPreview())
    }
    

    You can also find it here:

    https://gist.github.com/enkelmedia/f91ba5c9cad0fa2b67be5de07b83763c

  • Kurt Moskjaer Andersen 40 posts 95 karma points
    Nov 23, 2016 @ 16:30
    Kurt Moskjaer Andersen
    0

    Thank you very much for your feedback.

    Our customer is using version 1.4.5.1, but is it also usable with this version?

  • Markus Johansson 1701 posts 4879 karma points c-trib
    Nov 24, 2016 @ 17:28
    Markus Johansson
    0

    Hi!

    Yes I think everything will work except this since the NewsletterService was added in V2.

    var listOfNewslettersLast90Days = new NewsletterService(GlobalFactory.Current.NewsletterRepository).GetSent();

    Give it a try and see what happens?

  • Kurt Moskjaer Andersen 40 posts 95 karma points
    Nov 25, 2016 @ 06:43
    Kurt Moskjaer Andersen
    0

    Hi,

    Thank you for your response. I will give it a go :)

  • 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