Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 02, 2012 @ 14:50
    Fuji Kusaka
    0

    GetApprovedRecords from Comment List

    Hi Guys,

    Anyone can point out how do get ApprovedRecordsFromPage in Razor. Just like you would do in XSLT. 

     <xsl:template name="comments">
              <xsl:variable name="records" select="umbraco.contour:GetApprovedRecordsFromPage(@id)/uformrecord[state = 'Approved']"/>
               <xsl:choose>
                    <xsl:when test="count($records) = 0">
                      <href="{umbraco.library:NiceUrl(@id)}"(0) comments</a>
              </xsl:when>
            <xsl:when test="count($records) = 1">
              <href="{umbraco.library:NiceUrl(@id)}">(1) comment </a>
            </xsl:when>
            <xsl:otherwise>
              <href="{umbraco.library:NiceUrl(@id)}"(<xsl:value-of select="count($records)"/>)  Comments</a>
              
            </xsl:otherwise>
          </xsl:choose>
            </xsl:template>
    Can someone point out how to achieve this?

    //fuji

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jul 02, 2012 @ 18:13
    Jeroen Breuer
    0

    I don't know what that method returns, but in Razor you can probably just do this:

    var result = umbraco.contour.GetApprovedRecordsFromPage(id);

    Jeroen

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 02, 2012 @ 19:38
    Fuji Kusaka
    0

    Hi Jeroen,

    From Tim post here, i think i might need to add the assembly for the namespace to work.

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 03, 2012 @ 07:46
    Fuji Kusaka
    0

    Weird after copying the Contour.Addons.DynamicObjects.dll, I still cant save the razor file, which triggers me an error message missing Contour namespace.

     error CS0234: The type or namespace name 'contour' does not exist in the namespace 'umbraco' (are you missing an assembly reference?)
  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 03, 2012 @ 09:01
    Fuji Kusaka
    0

    Now that i got it working i cant get the Comment Value to display.

     

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using umbraco.MacroEngines
    @using Contour.Addons.DynamicObjects
    <ul>
    @foreach (dynamic record in Contour.Addons.DynamicObjects.Library.GetApprovedRecordsFromPage(@Model.Id))
    {
        <li>      
            @record.Created.ToString("dddd MMMM dd, yyy hh:mm tt")
             Posted by :@record.Name
            <p> Comment : @record.leaveacomment</p>
     </li>
     }
    </ul>

    Everything works well until when displaying the Approved "Comment" @record.leaveacomment

    Anyone??

     

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jul 03, 2012 @ 09:55
    Michael Latouche
    0

    Hi Fuji,

    I think you need to capitalize the first letter of the property name when using "." notation (see razor cheat sheet http://our.umbraco.org/projects/developer-tools/razor-dynamicnode-cheat-sheet).

    Have you already tried with @record.Leaveacomment?

    Cheers,

    Michael.

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 03, 2012 @ 10:14
    Fuji Kusaka
    0

    Hi Michael,

    Thanks for the replay but not working. I tried both 

    @record.GetField("Leaveacomment").Values[0]
    @record.Leaveacomment
  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jul 03, 2012 @ 10:26
    Michael Latouche
    0

    Hi Fuji,

    Do you get any error, or do you just get nothing displayed? Did you try with @record.GetProperty("leaveacomment").Value

    NB: if your property name is "leaveacomment", I think you need to use it as-is in the GetField method, without capitalizing the first letter.

    Cheers,

    Michael

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 03, 2012 @ 10:32
    Fuji Kusaka
    0

    Tried those as well but nothing is showing up apart from an error message "Error loading MacroEngine script"...

     

    //fuji

Please Sign in or register to post replies

Write your reply to:

Draft