+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Sitefinity Forums Control Customization

Sitefinity Forums Control Customization

9 posts, 1 answered
  1. Karandeep Singh
    Karandeep Singh avatar
    12 posts
    Registered:
    27 May 2010
    28 May 2010
    Link to this post
    Hi,

    I just started using Sitefinity CMS, I want to have forums for my website, using the inbuit forums controls in sitefinity CMS. I need some customizations in it:
    1. I need to edit the appearance and looks, how can i do that.
    2. Assuming that this website forum is also built in Sitefiniy CMS, i want to customize the appearance of threads and posts in a way that replies to the post by a specific user group (admins and MVPs) are clearly differentiated ( for example: the replies posted by admins can be in a blue color it shows a small image by the side of the author just like this website has)
    3. Second thing is that I want that posts in a forum are moderated for normal users but when an administrator or MVP posts a reply it should be visible straight away in the threads, is that possible?

    Please help
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 May 2010
    Link to this post
    Hello Karandeep Singh,

    The Sitefinity and Telerik forum is a custom implementation which is wrapped in Sitefinity. You could modify the appearance of the forums by adding css classes to your theme and changing the layout of forums templates located under \Sitefinity\ControlTemplates\Forums

    You could implement coloring of the replies and adding images by modifying SingleThread.ascx and EditPost.ascx template.

    In SingleThread.ascx there is a control called ManageProfile from where you could access the username of each use. Then you could pass the user name to the  ProfileBase class and get the user's image.  You could add an additional div that wraps the content of the post/thread and change the color depending on the user

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Karandeep Singh
    Karandeep Singh avatar
    12 posts
    Registered:
    27 May 2010
    28 May 2010
    Link to this post


    <prof:ManageProfile ID="userProfile" runat="server">
        <ViewTemplate>
            <h2><asp:Literal ID="FirstName" runat="server"></asp:Literal
            <asp:Literal ID="LastName" runat="Server"></asp:Literal></h2>
          
        </ViewTemplate>
    </prof:ManageProfile>
      
    </dt>
    <dt><asp:Label ID="anonymousName" runat="server" Text="Anonymous"></asp:Label></dt>
    <dd><asp:Literal ID="authorRole" runat="server"></asp:Literal></dd>
     

    can u please show me here how to access the username and pass it to the ProfileBase class.

    one other thing is that i want that user role is displayed below the Username.
    but it show's only administartors role not any other role other than administrators.



    Thanks,
    Karandeep Singh
  4. Karandeep Singh
    Karandeep Singh avatar
    12 posts
    Registered:
    27 May 2010
    28 May 2010
    Link to this post
    As I am new user, don't have much development experience, all the experience i have working with asp.net and c# is from school projects so I request you to be a little more descriptive.
    It would be best if u can show me some sample code from where i can have some idea for accessing controls properties in code.
    And I really appreciate your quick response to my first post, thanks for getting back to me. :)

    Thanks,
    Karandeep Singh
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 May 2010
    Link to this post
    Hi Karandeep Singh,

    Below is a sample code that illustrates how to access both instances of ManageProfile control inside SingleThread template and pass the data to ProfileBase object from where you could get/set provide properties.

    public void Page_Load(object sender, EventArgs e)
    {
     
       allPosts.ItemDataBound += new RepeaterItemEventHandler(allPosts_ItemDataBound);
     
    }
     
    void allPosts_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
           ManageProfile mProfile = e.Item.FindControl("userProfile") as ManageProfile;
        }
    }
     
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        string un = this.userProfile.Username;
        ProfileBase profile = ProfileBase.Create(un);
        var profileProperty = profile.GetPropertyValue("SomeProfileProperty");
    }


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  6. Karandeep Singh
    Karandeep Singh avatar
    12 posts
    Registered:
    27 May 2010
    01 Jun 2010
    Link to this post
    Hello Ivan,

    thanks a lot for the help. I also want to access the roles of the user so i can customize the appearance on the basis of user role. this is what i tried but it didn't work out.

    Dim un As String = Me.userProfile.Username
    Dim profile As ProfileBase = ProfileBase.Create(un)
     
    'Dim usr As Telerik.DataAccess.AspnetProviders.User = New Telerik.DataAccess.AspnetProviders.User()
    'Dim roles As String() = usr.GetRoles()
    'profile.SetPropertyValue("Role", roles)

    User class has an overloaded constructor that has parameters as (applicationID As Guid, Username As String)
    i am confused from where to get the application ID ?
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Jun 2010
    Link to this post
    Hi Karandeep Singh,

    You can use  UserManager.GetCurrentUserRoles(); to get all roles for the currently logged in user

    string[] userRoles =  UserManager.GetCurrentUserRoles();


    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Karandeep Singh
    Karandeep Singh avatar
    12 posts
    Registered:
    27 May 2010
    01 Jun 2010
    Link to this post
    Hi Ivan,

    I want to access the roles of the authors of all the posts in a singleThread(not the current user) so that i can customize the appearance of posts inside the repeater depending on the roles of a user. Please suggest me if there is some alternate solution too.


    Thanks

    Karandeep Singh
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Jun 2010
    Link to this post
    Hi Karandeep Singh,

    You could subscribe for PreRender event of ManageProfile control and access the user name. In allPosts_ItemDataBound it too early.

    void mProfile_PreRender(object sender, EventArgs e)
    {
        ManageProfile profiler = sender as ManageProfile;
        string[] allRoles = System.Web.Security.Roles.GetRolesForUser(profiler.Username);
    }

    The better option is creating a custom control that inherits from Telerik.Forums.WebControls.Forums and override CreateSingleThread(), but this is equivalent to write a new control.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
9 posts, 1 answered