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

Forums / Developing with Sitefinity / New Forum Post Property

New Forum Post Property

13 posts, 0 answered
  1. Brandon
    Brandon avatar
    16 posts
    Registered:
    23 Oct 2008
    14 Jul 2010
    Link to this post
    Hi,
    I've added a field to sf_frm_Post (ExpireDate) and I need to make it updateable in the admin module section.

    I've seen this thread: http://www.sitefinity.com/devnet/forums/sitefinity-3-x/developing-with-sitefinity/extending-existing-modules.aspx  but that seems like it's not for the forum modules.

    How should I go about this?

    Thanks,
    Brandon
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Jul 2010
    Link to this post
    Hi Brandon,

    You need to create a persistence class or use LINQ -SQL directly to get/enter data into the database.The article you have seen explains how to use GenenericContent based modules. These modules supports dynamic metafields which you can use to persist you data. The Forums module is not GenericContent based module which means you cannot just create a  column or add a filed in the database. You need to implement some logic to get it and set it.

    Greetings,
    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. Brandon
    Brandon avatar
    16 posts
    Registered:
    23 Oct 2008
    14 Jul 2010
    Link to this post
    Is there a way to extend the Admin Forum control(s) directly?  Or will I need to create a separate tool/module to manage this?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Jul 2010
    Link to this post
    Hello Brandon,

    The backend module could be extended, but it depends on what you want to do.

    All the best,
    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
  5. Brandon
    Brandon avatar
    16 posts
    Registered:
    23 Oct 2008
    14 Jul 2010
    Link to this post
    What I'd prefer is on the Thread/Post Edit page where the Invisible/Locked drop down is, is to put a TextBox where I could edit the Date and have it saved at the same time the user changes it (just like the Status drop down).  What I don't know how to do is add any functionality to that page. 

    I thought I could maybe even create a small User Control that does it, and stick it on the template, but I'd still need to tell it what PostID i'm working with somehow.

    Thanks,
    Brandon
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Jul 2010
    Link to this post
    Hi Brandon,

    The template that you have to modify is ~\Sitefinity\Admin\ControlTemplates\Forums\ControlPanelViewThreadTemplate.ascx

    You could subscribe for the ItemDataBound event of the repeater inside this template and access the post. From the post you can get

    • ((Telerik.Forums.Data.Post)post.Parent).ID - get parent Id
    • ((Telerik.Forums.Data.Post)post.Thread).ID - get thread Id
    • ((Telerik.Forums.Data.Forum)post.ForumID).ID - get Forum Id

    public void Page_Load(object sender, EventArgs e)
       {
     
           this.allPosts.ItemDataBound += new RepeaterItemEventHandler(allPosts_ItemDataBound);
       }
     
     
       void allPosts_ItemDataBound(object sender, RepeaterItemEventArgs e)
       {
           if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
           {
               Telerik.Forums.IPost post = (Telerik.Forums.IPost)e.Item.DataItem;
               if (post != null)
               {
                   var postId = post.ID;
               }
               
           }
       }

    Then you can add a button or another control that will be used to persist the data from your TextBox control.
    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
  7. Brandon
    Brandon avatar
    16 posts
    Registered:
    23 Oct 2008
    15 Jul 2010
    Link to this post
    Thank you for the in depth information.  I think I just have one more question and I'll be good to go.  I found the controltemplate, but what class should I inherit from?  I can't seem to find it. Also, how do I tell the Admin module to use my version instead of standard?  I didn't see anything in the web.config and I don't see a config section like in the Forum/SingleThread controls.

    Thanks,
    Brandon
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Jul 2010
    Link to this post
    Hi Brandon,

    You can work directly with the templates which are located in your project

    ~\Sitefinity\Admin\ControlTemplates\Forums
    ~\Sitefinity\ControlTemplates\Forums

    Forum module is not a Generic Content based module. The module is declared in the web.config <modules> section - Telerik.Forums.ForumsModule. There is <forums> section where the provider  and its settings are
    declared.

    If you want to work with the module classes you should inherit from ForumsModule and override ControlPanel and CommandPanel methods, but this is equal to creating a new module, so I suggest to work with the templates if possible.

    All the best,
    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
  9. Brandon
    Brandon avatar
    16 posts
    Registered:
    23 Oct 2008
    15 Jul 2010
    Link to this post
    Working with them directly sounds great however I'm confused I guess.  There's no code-behind for those controls.  Where would I put my code?  Do I just create a code behind file and put it in there?  If so should it be a partial class of some sort?
  10. Brandon
    Brandon avatar
    16 posts
    Registered:
    23 Oct 2008
    16 Jul 2010
    Link to this post
    So I added this code to the .ascx page itself:

    <script language="C#" runat="server">
     
       public void Page_Load(object sender, EventArgs e)
       {
     
          
            
           this.txtExpireDate.Text = "HIYA!!!!";  //ThisWorks
     
           this.allPosts.ItemDataBound += new RepeaterItemEventHandler(allPosts_ItemDataBound2);
           
            
       }
         
       void allPosts_ItemDataBound2(object sender, RepeaterItemEventArgs e)
       {
           if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
           {
               Telerik.Forums.IPost post = (Telerik.Forums.IPost)e.Item.DataItem;
               txtExpireDate.Text += "P"; //This doesn't work;
               if(post != null)
               {
                   var postId = post.ID;
                   txtExpireDate.Text += post.ID.ToString() + " ";  //This doesn't work;
               }
                
           }
       }
     
    </script>

    It seems that the listener isn't firing (maybe it's added after the code behind runs?).

    Another question I have however, is what's passed to the page? Is there a parentId or threadId sent as a parameter?  I don't really need to get each post of a thread, I just need the parentId / threadId and I can set its expiredate / children expire date, without needing to run through the whole repeater.

    Thanks,
    Brandon
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Jul 2010
    Link to this post
    Hello Brandon,

    I checked the code, but there should not be a problem with setting the Text of txtExpireDate. You could attach the code to debugger to see whether something else overrides its value later.

    As for the other question - you can get the parentID or threaID of the first post and then break instead of looping through all posts, because the parentId or threaID are the same for each post in the list.

    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
  12. Brandon
    Brandon avatar
    16 posts
    Registered:
    23 Oct 2008
    19 Jul 2010
    Link to this post
    Ok, hooked it up to a debugger and figured out why the ItemDataBound even was not populating my textbox - when there's only a Single Post in a thread, the ItemDataBound event does not fire.  Only when there are two or more posts in a thread does it fire.  Unfortunately the vast majority of our threads are single post threads.  Is there something else that happens that I can link in/subscribe to? Or another way to grab the PostID/ThreadId?

    Thanks,
    Brandon
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    19 Jul 2010
    Link to this post
    Hello Brandon,

    You can modify  \Sitefinity\Admin\ControlTemplates\Forums\ControlPanelAllThreadsTemplate.ascx. Inside Page_Load subscribe for allThreads2.RowCommand. When someone clicks on a thread you will be able to get the thread ID as a CommandArgument inside allThreads2_RowCommand event

    public void Page_Load(object sender, EventArgs e)
    {
        allThreads2.RowCommand += new GridViewCommandEventHandler(allThreads2_RowCommand);
    }
     
    void allThreads2_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        var id = e.CommandArgument.ToString();
        
    }

    Then you can save the value as a HidenField and use it.

    Greetings,
    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
13 posts, 0 answered