More in this section

Forums / Developing with Sitefinity / Editing Forums control for add funcionality

Editing Forums control for add funcionality

20 posts, 4 answered
  1. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    29 Dec 2009
    Link to this post
    Hello,

    Yesterday I finish the custom list for news I inherit from NewsView... ContentViewDesignerBase...  etc...

    When I have got a boolean in metadata in my new i display this new in my NewsViewCustom...

    Ok,

    and now i would like do this for Forums... but I don´t know... xD

    I haven´t got for override CreateDataSource, I haven´t got ItemListTemplatePath, etc... where is the class for do this in forums?

    In other words, How display my custom list of forums? I have a boolean in forums metadata and i would like, if this metadata is true display forum in list...

    I need the Forums control, not ForumsList control.

    Thanks, and merry christmas.

    Salu2,
    Pablo
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    29 Dec 2009
    Link to this post
    Hello xax_007,

    Forums module does not implement Generic Content structure. The forums module does not support metadata, which means that you have to create your own data layer to persists the properties value. The easiest way is using LINQ - SQL. queries. Then you can create a new class that derives from Forums and implent your logic. Another and easiest option would be working with Forums templates directly and accessing the data bound controls - GridView and Repeater. The templates are located under ~/Sitefinity/ControlTemplates/Forums/

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    30 Dec 2009
    Link to this post
    Hello Ivan,

    I prefer attack to class inherit forums, so i read this:

    http://www.sitefinity.com/blogs/radoslavgeorgiev/posts/09-12-03/group_appointments_by_event_categories_in_a_custom_events_schedule_view.aspx

    I think that is posible do something similar, I have got allForumsDataSource property, no EvensSchedulerDataSource obviusly, but I add my list to allForumsDataSource in a override of CreateChildControls...  not work,

    What more have are I doing in this method?

    Any suggestions?

    Thanks to all Telerik Team, you are very efficient and fast. :)

    Salu2,
    Pablo
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    30 Dec 2009
    Link to this post
    Hi xax_007,

    I could not find the relation between your first and second posts.  In the RadScheduler you can only show the forum posts, but it will not give you any opportunity to save any data which should be persisted.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    04 Jan 2010
    Link to this post
    Do not want to show the forums in a radScheduler, I show them in Telerik.Forums.WebControls.Forums... but in a custom list.

    I not have a metadata, I have a property save in a custom table in data base with forum id...

    I need the property o method for do my custom list of forums, ¿Is posible?

    Thanks for reply.

    Salu2,
    Pablo
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Jan 2010
    Link to this post
    Hi xax_007,

    Please elaborate some more on the requirement you have. I cannot understand what you are asking for. You are referring to a different posts where completely different implementation, controls and items are used.

    If someone else of the community could understand your task and help you it will be great.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    04 Jan 2010
    Link to this post

    Thanks for reply Ivan.

    Ok, I would like do a custom list of forums for diplay in Telerik.Forums.WebControls.Forums.

    If i call a base.CreateChildControls() of this class, the control diplay me all forums.

    but I have in my database forums with forums id true or false, depending is in home or not.

    Now, I get all forums with forums manager, foreach them, and if in my table forum id have the filed true, I would display this forum but not all forums in control..

    I have explained it better?

    The result i would like is:

    foreach all forums, filters this forums with my boolean, and diplay filtered forums only.
    But i find a variable allForumsDataSource in Telerik.Forums.WebControls.Forums class, I assign my filtered forums to this variable, but not diplay nothing and if i call to base.createchildcontrols() display all forums.

    What I can doing?

    My code block:

    //In class inherit of Telerik.Forums.WebControls.Forums

    protected
     override void CreateChildControls()  
    {  
                //Creamos la lista que alberga todos los foros para pasarlos y mostrarlos más tarde  
                List<IForum> forumList = new List<IForum>();  
     
                //Instanciamos el manager del foro.  
                ForumManager forumsManager = new ForumManager("Sitefinity");  
          
                foreach (IForum _forum in forumsManager.GetForums(true))  
                {  
                     dsForums.ForumsInHomeDataTable dtForums = (new dsForumsTableAdapters.ForumsInHomeTableAdapter()).GetIsForumInHome(_forum.ID)  
     
                     foreach(dsForums.ForumsInHomeDataRow rowForumIsInHome in dtForums)  
                     {  
                          if(rowForumIsInHome.BooleanIsInHome)  
                          {  
                               forumList.Add(_forum);  
                          }                   
                     }  
                         
                }  
     
                this.allForumsDataSource = forumList;  
     
     
                //HERE IS MY PROBLEM, NOW WHAT I DO?  


    Salu2,
    Pablo


  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Jan 2010
    Link to this post
    Hello xax_007,

    When you call the base it is normal to see all forum posts, because your class derives from the base class. Depending on your need you have to override CreateAllForums() or CreateSingleForum() and there bind the repeater control to your custom data source.

    sample

    this.allForumsDataSource = this.manager.GetCategories();
     
    this.cntAllForums.ForumsRepeater.DataSource = this.MyDataSource;
    this.cntAllForums.ForumsRepeater.ItemCreated += new RepeaterItemEventHandler(ForumsRepeater_ItemCreated);
    this.cntAllForums.ForumsRepeater.ItemDataBound += new RepeaterItemEventHandler(ForumsRepeater_ItemDataBound);
    this.cntAllForums.ForumsRepeater.DataBind();
     
    IList uncategorizedForums = this.manager.GetForumsUncategorized(true);
    if (uncategorizedForums.Count == 0)
        this.cntAllForums.UncategorizedHeader.Text = String.Empty;
     
    this.cntAllForums.Uncategorized.DataSource = this.MyDataSource;
    this.cntAllForums.Uncategorized.RowCreated += new GridViewRowEventHandler(ForumsGrid_RowCreated);
    this.cntAllForums.Uncategorized.RowDataBound += new GridViewRowEventHandler(ForumsGrid_RowDataBound);
    this.cntAllForums.Uncategorized.RowCommand += new GridViewCommandEventHandler(ForumsGrid_RowCommand);
    this.cntAllForums.Uncategorized.DataBind();


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  9. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    04 Jan 2010
    Link to this post
    Hello Ivan thanks for this code block,
     
    I´m doing this in CreateAllForums()

                //Creamos la lista que alberga todos los foros para pasarlos y mostrarlos más tarde        
                List<IForum> forumList = new List<IForum>();        
           
                //Instanciamos el manager del foro.        
                ForumManager forumsManager = new ForumManager("Sitefinity");        
                
                foreach (IForum _forum in forumsManager.GetForums(true))        
                {        
                     dsForums.ForumsInHomeDataTable dtForums = (new dsForumsTableAdapters.ForumsInHomeTableAdapter()).GetIsForumInHome(_forum.ID)        
           
                     foreach(dsForums.ForumsInHomeDataRow rowForumIsInHome in dtForums)        
                     {        
                          if(rowForumIsInHome.BooleanIsInHome)        
                          {        
                               forumList.Add(_forum);        
                          }                         
                     }        
                               
                }        
           
                this.allForumsDataSource = forumList;      
       
     
                this.cntAllForums = new AllForumsContainer(this);  
     
     
                Repeater repiter = new Repeater();  
     
                repiter.ID = "forumsRepeater";  
                repiter.DataSource = forumList;  
                repiter.DataBind();  
     
                this.cntAllForums.Controls.Add(repiter);  
     
                this.cntAllForums.ForumsRepeater.DataSource = forumList;  
                this.cntAllForums.ForumsRepeater.DataBind();  
       
     

    with this Telerik.Forums.WebControls.Forums class diplay nothing but i have 3 items in forumlist,

    whit this:
    //Creamos la lista que alberga todos los foros para pasarlos y mostrarlos más tarde           
                List<IForum> forumList = new List<IForum>();           
              
                //Instanciamos el manager del foro.           
                ForumManager forumsManager = new ForumManager("Sitefinity");           
                   
                foreach (IForum _forum in forumsManager.GetForums(true))           
                {           
                     dsForums.ForumsInHomeDataTable dtForums = (new dsForumsTableAdapters.ForumsInHomeTableAdapter()).GetIsForumInHome(_forum.ID)           
              
                     foreach(dsForums.ForumsInHomeDataRow rowForumIsInHome in dtForums)           
                     {           
                          if(rowForumIsInHome.BooleanIsInHome)           
                          {           
                               forumList.Add(_forum);           
                          }                            
                     }           
                                  
                }           
              
                this.allForumsDataSource = forumList;         
          
        
                this.cntAllForums = new AllForumsContainer(this);     
     
                this.cntAllForums.ForumsRepeater.DataSource = forumList;     
                this.cntAllForums.ForumsRepeater.DataBind();     
     

    the control not find a Repeter with id forumsRepeater.

    Can you explained the code block example?

    Thanks.

    Salu2,
    Pablo
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Jan 2010
    Link to this post
    Hello xax_007,

    You do not have to add a new repeater and event more dynamically. You have to bind the build in repeater the your data source as the code I sent you shows. More information about repeater control databinding can be found at Repeater Class

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    04 Jan 2010
    Link to this post
    Attach is the error if I not create new repeater with the ID.

    I thing that maybe I´m forgetting something...

    Is this error problem from repeater?

    Salu2,
    Pablo

  12. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    04 Jan 2010
    Link to this post
    Hello xax_007,

    I do not know Spanish, but I think the error says that you are missing a required control on the template. This required controls is of type System.Web.UI.WebControls.Repeater and its ID of this control should be "forumsRepeater". Did you remove the repeater control from the control template markup? This control is required, therefore it should not be removed from the markup. If you do not want it to appear you should just set its Visible="false" property.

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  13. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    04 Jan 2010
    Link to this post
    ... ¿I need template for Telerik.Forums.WebControls.Forums class?

    well, was not conscious of it...

    but I have tmpAllForums is a variable in this class i suppose that here is where i put the template... what template i need?

    I don´t know Sitefinity API, i´m not developer of this. sorry :(

    Sitefinity are closed assembly, if i will have the source code of the complet project, another birth sing

    But with this, only have this forums, blogs, and your WebSite...

    I would like not bother much but the documentation is very simple.

    Thak you very much, Ivan

    Salu2,
    Pablo

  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Jan 2010
    Link to this post
    Hello xax_007,

    You have o InstantiateIn the template for the control. Below is a sample code that you need to observe

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Forums.WebControls;
    using System.Collections;
    using System.Web.UI.WebControls;
    using Telerik.Framework.Web;
    using System.Web.UI;
     
    public class Class22 : Forums
    {
        public Class22()
        {
         
        }
     
        protected override void CreateAllForums()
        {
            IList MyDataSource = manager.GetForums(false);
            this.cntAllForums = new AllForumsContainer(this);
            if (this.tmpAllForums == null)
            {
                this.tmpAllForums = ControlUtils.GetTemplate<DefaultAllForumsTemplate>(this.manager.Provider.ForumListTemplate);
            }
            this.tmpAllForums.InstantiateIn(this.cntAllForums);
            this.Controls.Add(this.cntAllForums);
            if (cntAllForums != null)
            {
                this.cntAllForums.ForumsRepeater.DataSource = MyDataSource;
                this.cntAllForums.ForumsRepeater.ItemCreated += new RepeaterItemEventHandler(ForumsRepeater_ItemCreated);
                this.cntAllForums.ForumsRepeater.ItemDataBound += new RepeaterItemEventHandler(ForumsRepeater_ItemDataBound);
                this.cntAllForums.ForumsRepeater.DataBind();
     
                IList uncategorizedForums = this.manager.GetForumsUncategorized(true);
                if (uncategorizedForums.Count == 0)
                    this.cntAllForums.UncategorizedHeader.Text = String.Empty;
     
                this.cntAllForums.Uncategorized.DataSource = MyDataSource;
                this.cntAllForums.Uncategorized.RowCreated += new GridViewRowEventHandler(Uncategorized_RowCreated);
                this.cntAllForums.Uncategorized.RowDataBound += new GridViewRowEventHandler(Uncategorized_RowDataBound);
                this.cntAllForums.Uncategorized.RowCommand += new GridViewCommandEventHandler(Uncategorized_RowCommand);
                this.cntAllForums.Uncategorized.DataBind();
            }
     
        }
     
           
        void Uncategorized_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //throw new NotImplementedException();
        }
     
        void Uncategorized_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //throw new NotImplementedException();
        }
     
        void Uncategorized_RowCreated(object sender, GridViewRowEventArgs e)
        {
            //throw new NotImplementedException();
        }
     
        void ForumsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
           // throw new NotImplementedException();
        }
     
        void ForumsRepeater_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
           // throw new NotImplementedException();
        }
     
        private class DefaultAllForumsTemplate : ITemplate
        {
            public void InstantiateIn(Control container)
            {
     
            }
        }
        
    }

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  15. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    04 Jan 2010
    Link to this post
    Ivan you are a maquine, thanks & thanks

    This work correctly I have the filtered forums list...

    but a litlle detail...

    this.manager.Provider.ForumListTemplate only show the titile (name) from forum, I can´t click in the title or name forum for go to the forum detail, open thread... open or reply posts...

    Attach have a example of my filtered forums list...
  16. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Jan 2010
    Link to this post
    Hi xax_007,

    You have to implement the logic inside all events where "throw new NotImplementedException();" is commented and especially in ForumsGrid_RowDataBound

    sample

    void ForumsGrid_RowDataBound(object sender, GridViewRowEventArgs e)
           {
               GridViewRow row = e.Row;
               if (row.RowType == DataControlRowType.DataRow)
               {
                   LinkButton buttonSelect = (LinkButton)row.FindControl("btnOpenForum");
                   buttonSelect.Text = ((IForum)row.DataItem).Name;
                   buttonSelect.CommandName = "OpenForum";
                   buttonSelect.CommandArgument = ((IForum)row.DataItem).ID.ToString();
     
     
                  ....
                     ....
               }
            }


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  17. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    04 Jan 2010
    Link to this post
    Perfect, this show my the title in forums GridView,

    so There are documentation for this?

    How I know the id of controls?

    How I know the CommandName from Telerik API?

    I´m see ~/Sitefinity/ControlTemplates/Forums/ForumList.ascx and i thing that can be here.

    I find the ids
    btnOpenForum
    lblDescription,
    forumStatus
    goToPost
    lastPostAuthor
    etc...

    but not the commands name or implementing for this commands... do things...

    The true is that you help me very much...

    Salu2,
    Pablo




  18. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    13 Jan 2010
    Link to this post
    Hello Telerik Team,

    I am testing for forum for this:

    void Uncategorized_RowCommand(object sender, GridViewCommandEventArgs e)  
        {  
            //throw new NotImplementedException();  
        }  
       
        void Uncategorized_RowDataBound(object sender, GridViewRowEventArgs e)  
        {  
            //throw new NotImplementedException();  
        }  
       
        void Uncategorized_RowCreated(object sender, GridViewRowEventArgs e)  
        {  
            //throw new NotImplementedException();  
        }  
       
        void ForumsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)  
        {  
           // throw new NotImplementedException();  
        }  
       
        void ForumsRepeater_ItemCreated(object sender, RepeaterItemEventArgs e)  
        {  
           // throw new NotImplementedException();  
        }  
       
        private class DefaultAllForumsTemplate : ITemplate  
        {  
            public void InstantiateIn(Control container)  
            {  
       
            }  
        } 

    but i don´t know how or wath do the forum control base behavior...

    Have you an example similar to this for the before throws:

    void ForumsGrid_RowDataBound(object sender, GridViewRowEventArgs e)  
           {  
               GridViewRow row = e.Row;  
               if (row.RowType == DataControlRowType.DataRow)  
               {  
                   LinkButton buttonSelect = (LinkButton)row.FindControl("btnOpenForum");  
                   buttonSelect.Text = ((IForum)row.DataItem).Name;  
                   buttonSelect.CommandName = "OpenForum";  
                   buttonSelect.CommandArgument = ((IForum)row.DataItem).ID.ToString();  
       
       
                  ....  
                     ....  
               }  
            } 


    Salu2,
    Pablo
  19. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    13 Jan 2010
    Link to this post
    Hi xax_007,

    Below is a sample implementation for ForumsGrid_RowCommand

    void ForumsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
         {
             switch (e.CommandName)
             {
                 case "OpenForum":
                     this.selectedForumID = new Guid(e.CommandArgument.ToString());
                     if (String.IsNullOrEmpty(this.singleForumPage))
                         this.mode = Mode.SingleForum;
                     else
                         HttpContext.Current.Response.Redirect(this.singleForumPage + "?mode=singleForum&forum=" + this.selectedForumID.ToString());
                     base.ChildControlsCreated = false;
                     break;
                 case "OpenThread":
                     IPost selectedThread = this.manager.GetPost(new Guid(e.CommandArgument.ToString()));
                     this.selectedThreadID = selectedThread.ID;
                     this.selectedForumID = selectedThread.ForumID.ID;
                     if (String.IsNullOrEmpty(this.singleThreadPage))
                         this.mode = Mode.SingleThread;
                     else
                         HttpContext.Current.Response.Redirect(this.singleThreadPage + "?mode=singleThread&thread=" + this.selectedThreadID.ToString());
                     base.ChildControlsCreated = false;
                     break;
             }
         }


    You have to complete the logic for the other methods.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  20. xax_007
    xax_007 avatar
    55 posts
    Registered:
    24 Jul 2009
    13 Jan 2010
    Link to this post
    This work Perfect.

    Thanks Ivan.

    Salu2,
    Pablo

Register for webinar
20 posts, 4 answered