Copied to clipboard

Flag this post as spam?

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


  • Kim Bantz Rasmussen 81 posts 310 karma points
    Feb 18, 2013 @ 11:13
    Kim Bantz Rasmussen
    0

    Show list of comments - multilanguage

    Hi,

    I want to show a list of comments, but my problem is that my fields are called #Comment-Comment, #Comment-Name because the site is multilanguage ...

    I have tried this razorscript:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    
    @using Contour.Addons.DynamicObjects
    
    <div id="comments" class="row">
    
    @foreach (dynamic record in Contour.Addons.DynamicObjects.Library.GetApprovedRecordsFromPage(@Model.Id).OrderBy("Created"))  
     {
         <div class="six columns">
             <div>
                 <i class="icon-quote-left">@Html.Raw("")</i>
                 @record.Comment.ToString()  
                 <span>@record.Name.ToString() - @record.Created.ToString("dd MMMM yyy")</span> 
            </div>     
         </div>
      }
    </div>

     

    And I don't know have to modify this XSLT to get the name field (#Comment-Name) for example:

    <xsl:variable name="records" select="umbraco.contour:GetApprovedRecordsFromPage($currentPage/@id)/uformrecord[state = 'Approved']" />
    
        <!-- Display the number of records -->
        <div id="recordscount">
          <xsl:choose>
            <xsl:when test="count($records) = 0">
              (0) comments
            </xsl:when>
            <xsl:when test="count($records) = 1">
              (1) comment
            </xsl:when>
            <xsl:otherwise>
              (<xsl:value-of select="count($records)"/>)  Comments
            </xsl:otherwise>
          </xsl:choose>
        </div>
    
    
        <textarea><xsl:copy-of select="umbraco.contour:GetRecordsFromForm('7a307e8c-d592-4dd8-a6ba-0e711f4a9b2e')"/></textarea>
    
    
        <div id="records">
    
          <!-- Loop all records -->
          <xsl:for-each select="$records">
            <div class="record">
                <div class="commentTxt">
                    <!-- Display 'Comment' field of the record, make sure there is a field called 'Comment' on the form -->
    
                     <xsl:value-of select="umbraco.library:ReplaceLineBreaks(.//fields/Comment//value)" disable-output-escaping="yes"/>
                </div>
    
            </div>
          </xsl:for-each>
    
        </div>     

    Best regards
    Kim

  • Comment author was deleted

    Feb 18, 2013 @ 11:36

    In razor could you try without the # so @record.Comment-Comment an if that doesn't work try @record.CommentComment

    Let me know if that does the trick

  • Comment author was deleted

    Feb 18, 2013 @ 11:37

    Same for xslt try without the # and withough the -

  • Comment author was deleted

    Feb 18, 2013 @ 11:38

    btw the dynamic object are part of Contour if you use v3 and up (not sure the addons you are using support the dictionary)

  • Comment author was deleted

    Feb 18, 2013 @ 11:41

    Well for the xslt one you should be able to see the xml in the textarea

    <textarea><xsl:copy-ofselect="umbraco.contour:GetRecordsFromForm('7a307e8c-d592-4dd8-a6ba-0e711f4a9b2e')"/></textarea>

    So that should show you how the element is named

  • Kim Bantz Rasmussen 81 posts 310 karma points
    Feb 18, 2013 @ 13:00
    Kim Bantz Rasmussen
    0

    Hi Tim,

    The xslt works with:

    <xsl:value-of select="umbraco.library:ReplaceLineBreaks(.//fields/commentcomment//value)" disable-output-escaping="yes"/>

    For the field '#Comment-Comment' - So that's great!

    Sadly, I didn't get the Razor script to work :( Even with different combinations of @record.Comment-Comment

    But Thanks for your help!

Please Sign in or register to post replies

Write your reply to:

Draft