1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Post thread from ViewPublic extending class

Discussion in 'XenForo Development Discussions' started by Robin De Schepper, Aug 14, 2013.

  1. Robin De Schepper

    Robin De Schepper New Member


    I just started developing add-ons for XenForo and I have a small question. I've been looking into the XenForo DataWriter class to write posts from my add-on but I need some kind of Forum class. Is there any way I can initialise a Forum class from the renderHtml environment in a ViewPublic extending class? Preferably something like $forum = SomeStaticIDontKnow::getForumModel($forumId)?

    EDIT: I got lucky going through the source code and figured some stuff out. Would this work?
    $forumId = 1;
    $forumModel = XenForo_Model::create('XenForo_Model_Forum');
    $forum = $forumModel->getForumById($forumId);
    Example code of the simplest way to create a post in a forum would be much appreciated too :)

    Also, is there developer documentation about all the classes analog to MSDN for the .NET framework?
    Last edited: Aug 14, 2013
  2. Jeremy

    Jeremy Well-Known Member

    The _getXModel functions are defined per class and are usually short code for:
    You may want to look into how XenForo posts threads to a specific forum. XenForo_ControllerPublic_Forum::actionAddThread(); contains the necessary logic.
  3. Jeremy

    Jeremy Well-Known Member

    Yes, those actions correspond to the URL routes. However, you shouldn't be calling the controller action directly, you should just read it and learn how its doing that and write similar code in your add-on.

    Create a thread is a POST action, you can see the data by inspecting the network as you create one.
    Pereira likes this.

Share This Page