Dave Burke : Online Community and Social Business Specialist

CS Nuglet: Determining first forum thread post for custom UI display

I needed to display a graphic under the user avatar on the first forum thread post today and found it to be an interesting little task.  Essentially I took an approach similar to highlighting an author's comment in CS2008.5, which I always thought was pretty slick.  You'll find that on …/hawaii/post.aspx.  Look for IsAuthor().

For our purposes of displaying a graphic in the first forum thread post under the user avatar, we add a Conditional Content control with a custom IsFirstPost() method.

 

<CSControl:ConditionalContent ID="ConditionalContent1" runat="server">
    <ContentConditions>
       
<CSControl:CustomCondition ID="CustomCondition1"
            runat="server" CustomResult='<%# IsFirstPost(Eval("Subject")) %>' />
    </ContentConditions>
    <TrueContentTemplate>
        My cool graphic...
    </TrueContentTemplate>
    <FalseContentTemplate />
</CSControl:ConditionalContent>

 

Our IsFirstPost() method checks if the subject begins with "Re:" to indicate it's a reply.  I've scoured the ForumPost object for a distinct property to use instead, but didn't find one I liked.  Or else I was approaching it wrong.  Regardless, the subject "Re:" test works just fine.

 

<script runat="server" language="C#">

    bool IsFirstPost(object subject)
    {
        bool isFirstPost = true;
        if (subject.ToString().Substring(0,3) == "Re:")
            isFirstPost = false;
        return (isFirstPost);
    }

</script>


Now my cool graphic appears under the user avatar of the first forum thread post only.

Comments (2) | Post RSS RSS comment feed

Posted on 1/21/2009 7:29:54 PM by Dave Burke
Categories: Community Server
Tags:

Related posts

Comments (2) -

1/30/2009 11:07:51 AM Permalink

Wouldn't PostID == ParentID have done the trick?

Alex United Kingdom |

1/30/2009 11:33:58 AM Permalink

Hm!  If Afscrome said it would have done the trick, then I'm sure it would!  Thanks for the comment.  I'm always happy to be corrected for simplicity sake.

Dave Burke United States |


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke

Copyright © 2013 Dave Burke.  All Rights reserved.