Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity 3.x: Developing with Sitefinity > Accessing Comments ID property

Accessing Comments ID property

  • ddblee avatar

    Posted on Sep 24, 2008 (permalink)

    In the CommentItem repeater control inside  ~/Sitefinity/ControlTemplates/Blogs/Modes/ListPageDetail.ascx, I want to display the Comment ID, using a standard label control.

    What's the best way to get that property?

    Thanks!

    Reply

  • ddblee avatar

    Posted on Sep 25, 2008 (permalink)

    Still not gotten anywhere on my own, so would appreciate some help.

    Thanks!

    Reply

  • Posted on Sep 25, 2008 (permalink)

    Hi ddblee,

    I toyed with this for awhile, but I'm sorry to report I don't have a solution for you.

    You can add a label to the ControlTemplate easily enough.  However, it's the code-behind that is obviously responsible for doing something with that label. 

    In this case, the code-behind we're talking about is part of the compiled Sitefinity product.  This code is looking for very specific server tags and I don't believe it is looking for a label to populate with a Comment ID.  This means any labels you add, will just sit empty.

    I thought briefly about adding a custom UserControl to the ControlTemplate and using this control to get access to the root Comments' object that is being databound to the other controls.

    I'm not sure this is possible though.  Your only solution might be to create your own custom control for displaying blog posts. 

    Perhaps others have better ideas though...

    Gabe Sumner


    Reply

  • ddblee avatar

    Posted on Sep 26, 2008 (permalink)

    Thanks for the response, Gabe.

    Here's why I want to do what I asked about:
    for our implementation of Blogs, we want to record user input around "Was this comment helpful?" and also record reports of inappropriate comments. To facilitate that, we designed an approach involving some tables added to the database, where the comment ID would be the foreign key. So, being able to grab the comment ID is critical.

    However, if there is a cleaner way to achieve the same result within the Sitefinity framework, I'd love to hear it.

    Thanks!

    Reply

  • Sonya Sonya admin's avatar

    Posted on Sep 26, 2008 (permalink)

    Hi ddblee,

    You could achieve the functionality you desire by adding the highlighted code to
    ~/Sitefinity/ControlTemplates/Blogs/Modes/ListPageDetail.ascx
    <div class="sf_singlePost"
        ... 
    </div> 
     
    <div class="sf_postComments" runat="server" id="postCommentsPlh"
        <sfWeb:BlogCommentsList ID="commentsList" runat="server" CssClass="sf_commentsList"
            <Template> 
            <asp:Repeater ID="commentsRepeater" runat="Server"
        <HeaderTemplate> 
           ... 
        </HeaderTemplate> 
        <ItemTemplate> 
            ID: <%#DataBinder.Eval(Container.DataItem, "ID") %> 
     
            <!-- comment goes here --> 
            <sfWeb:CommentItem Id="anonCommentContainer" runat="server" CssClass="sf_anonymousComment" >  
              ... 
            </sfWeb:CommentItem> 

    Let me know if you need further assistance.

    Best wishes,
    Sonya
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

  • ddblee avatar

    Posted on Oct 17, 2008 (permalink)

    Hello!

    I need to be able to access this same property from within
    <sfWeb:CommentItem ID="anonCommentContainer" runat="server" CssClass="sf_anonymousComment">
                            <Template>
    ...
                            </Template>
                        </sfWeb:CommentItem>

    But, using the expression you provided, I get an error:
    'Telerik.Cms.Engine.WebControls.CommentItem.CommentContainer' does not contain a definition for 'DataItem' and no extension method 'DataItem' accepting a first argument of type 'Telerik.Cms.Engine.WebControls.CommentItem.CommentContainer' could be found (are you missing a using directive or an assembly reference?)    C:\tribaldev\lowes\lci\Sitefinity\ControlTemplates\Blogs\Modes\ListPageDetail.ascx

    How would I re-work this expression to resolve the ID from within the <Template> node?

    Thanks!

    Reply

  • Sonya Sonya admin's avatar

    Posted on Oct 24, 2008 (permalink)

    Hello ddblee,

    Please excuse us for the delay of our response. The container item is not accessible from within a comment item - it is private. So, unfortunately, we could not suggest any solution for this request.

    Regards,
    Sonya
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

  • Register for webinar
Skip Navigation LinksHome / Developer Network / Forums / Sitefinity 3.x: Developing with Sitefinity > Accessing Comments ID property