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

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 10, 2014 @ 08:45
    Tim Geyssens
    0

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

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 10, 2014 @ 08:47
    Tim Geyssens
    0

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

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 10, 2014 @ 08:48
    Tim Geyssens
    0

    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!

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 10, 2014 @ 11:38
    Tim Geyssens
    0

    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

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 10, 2014 @ 12:35
    Tim Geyssens
    0

    Ah glad that workaround did the trick, will do!

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 13, 2014 @ 09:34
    Tim Geyssens
    0

    Looking into the bug now, just been able to reproduce

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

    Also have the bug where GetApprovedRecordsFromPage returns all records

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 21, 2014 @ 13:30
    Tim Geyssens
    100

    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 :)

  • 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