Copied to clipboard

Flag this post as spam?

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


  • Kerri Mallinson 113 posts 497 karma points
    Oct 02, 2014 @ 17:24
    Kerri Mallinson
    0

    GetApprovedRecordsFromPage not working

    Hi I'm using Umbraco 7.1.4 and Contour 3.0.21

    I have a comments form and Manual Approval is set to true in settings The records are being added to the database as 'Submitted' not 'Approved' but they are still appearing on the page using .GetApprovedRecordsFromPage

    Here is the code:

    @using Umbraco.Forms.Mvc.DynamicObjects
    <ul>
    @foreach (dynamic record in Library
    .GetApprovedRecordsFromPage(@CurrentPage.Id).OrderBy("Created"))
    {
     <li>
          @record.Created.ToString("dd MMMM yyy")
             <strong>@record.Name</strong>
         <span>said</span>
        <p>@record.Comment</p>
     </li>
    }
    </ul>
    

    Thanks

  • Kerri Mallinson 113 posts 497 karma points
    Oct 09, 2014 @ 10:09
    Kerri Mallinson
    0

    Can anyone help with this? The comment functionality is the reason we paid for this package but it's no good if we can't only show approved comments.

    Thanks

  • Comment author was deleted

    Oct 10, 2014 @ 08:45

    Sounds like a bug, looking into it, eta for a fix early next week

  • Comment author was deleted

    Oct 10, 2014 @ 08:47

    As a temp workaround you can filter on state in your code since the record has a State property

  • Comment author was deleted

    Oct 10, 2014 @ 08:48

    so add if(record.State = Umbraco.Forms.Core.Enums.Approved)

  • Kerri Mallinson 113 posts 497 karma points
    Oct 10, 2014 @ 10:34
    Kerri Mallinson
    0

    Thanks Tim,

    I'm getting this error with the work around:

    CS1061: 'Umbraco.Web.UmbracoHelper' does not contain a definition for 'Forms' and no extension method 'Forms' accepting a first argument of type 'Umbraco.Web.UmbracoHelper' could be found (are you missing a using directive or an assembly reference?)

    The full code is:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Umbraco.Forms.Mvc.DynamicObjects
    @{
    Layout = "Master.cshtml";
    }
    @{
    var header = Umbraco.TypedMedia(Model.Content.GetPropertyValue<int>("headerImage"));
    var date = umbraco.library.FormatDateTime(CurrentPage.articleDate.ToString(), "dd MMMM yyyy"); 
    }
    <div id="banner" data-0="background-position:50% 0%;" data-500="background-position:50% 100%;" style="background-image: url(@header.Url);">
    </div>
        <div class="container left">
            <div class="row">
                <div class="col-sm-4 hidden-xs">
                    <h4>@date
                    <br />@CurrentPage.blogAuthor</h4>
                    @Html.Partial("BlogNav")
                    @Html.Partial("ShareButtons")
                    @Html.Partial("ArticleTags")
                    @Html.Partial("NewsletterSignup")
                </div>
                <div class="col-sm-8">
                    <h3>@CurrentPage.strapline</h3>
                    <hr />
                    <div id="article-content">
                        @Html.Raw(CurrentPage.copy)
                        <p>Comments</p>
    
                        <ul>
                            @foreach (dynamic record in Library
                            .GetApprovedRecordsFromFormOnPage(@CurrentPage.Id, "a33307a9-6788-446b-ab3e-3b3e62f7f97e").OrderBy("Created"))
                            {
                                    if(record.State = Umbraco.Forms.Core.Enums.Approved)
                                {
                                    <li>
                                        @record.Created.ToString("dd MMMM yyy")
                                        <strong>@record.Name</strong>
                                        <span>said</span>
                                        <p>@record.Comment</p>
                                        <p>@record.State</p>
                                    </li>
                                }
                            }
                        </ul>
    
                        @Umbraco.RenderMacro("umbracoContour.RazorRenderForm", new {FormGuid="a33307a9-6788-446b-ab3e-3b3e62f7f97e"})
                    </div>
                </div>
            </div>
        </div>
    
        @Html.Partial("RelatedBlogPosts")
    
        @Html.Partial("ContactBar")
    

    What am I missing? Cheers!

  • Comment author was deleted

    Oct 10, 2014 @ 11:38

    try adding using statement 

    using Umbraco.Forms.Core.Enums;

    and then is should be

    if(record.State == FormState.Approved)
  • Kerri Mallinson 113 posts 497 karma points
    Oct 10, 2014 @ 12:27
    Kerri Mallinson
    0

    Cheers Tim,

    That worked, will you post back when there is fix to the .GetApprovedRecordsFromPage?

    Ta

  • Comment author was deleted

    Oct 10, 2014 @ 12:35

    Ah glad that workaround did the trick, will do!

  • Comment author was deleted

    Oct 13, 2014 @ 09:34

    Looking into the bug now, just been able to reproduce

  • Tom 713 posts 954 karma points
    Oct 14, 2014 @ 04:55
    Tom
    0

    Also have the bug where GetApprovedRecordsFromPage returns all records

  • Comment author was deleted

    Oct 21, 2014 @ 13:30

    Bug is fixed and will be part of a 3.0.22 release coming shortly

  • Kerri Mallinson 113 posts 497 karma points
    Oct 21, 2014 @ 14:38
    Kerri Mallinson
    0

    Great, Thanks Tim :)

Please Sign in or register to post replies

Write your reply to:

Draft