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

Need to know file names where move thread code is present

Discussion in 'XenForo Development Discussions' started by gginni, Apr 20, 2013.

  1. gginni

    gginni Active Member

    Hi,

    I want to do some custom things while moving thread in particular forum. I know PHP and I did same for mybb code with pretty ease but here you guys have used framework, so it is taking a lot of efforts to understand. Do you guys have any developers guide??

    I actually want to do some custom coding while moving thread.

    I checked the template and it is post request to "threads/move" but I'm unable to find in which file should I make changes...

    Let's say I add a text box in move thread popup. Now I need to read the textbox value on submit button and do some mysql operation. Just tell me file name, remaining things I will do at my own :)
     
  2. James

    James Well-Known Member

    You will be looking in XenForo_ControllerPublic_Thread and the function will be actionMove() (line 1001)

    XenForo_ControllerPublic_Thread is located at library/XenForo/ControllerPublic/Thread.php.

    You'll be better off creating an add-on rather than edit the existing XF code.
     
    gginni likes this.
  3. gginni

    gginni Active Member

    Thanks a lot bro :)... I know it is not advisable to change the existing XF code directly but bro this is for personal use and I want to do things bit faster :)

    Thanks for telling file name and function name :)... You saved my efforts :)... I will do the required changes now :)
     
  4. tyteen4a03

    tyteen4a03 Well-Known Member

    It's not "faster". When you upgrade to 1.2 (or even just 1.1.5) everything will be overridden so you will have to do the changes again.

    Best way is to extend the relevant class and create a listener. In this case you can even disable the change if it breaks your forum.
     
  5. gginni

    gginni Active Member

    It will take time for me to learn how to create listeners ... I wanted to get things faster so that I can go live with the forum... Now I have done the required changes in that function only and those are minor changes... Even if upgrade will come then I can again replace those lines in the same file

    And I will surely look at how to create listeners and all and after that will not be playing with xenforo files directly :).. It is just need of an hour coz I want to get things done fast :)
     
  6. tyteen4a03

    tyteen4a03 Well-Known Member

    It doesn't. All you need is:

    Listener.php
    Code:
    class SomeClass_Listener {
        public static function loadClassController($class, array &$extend) {
            switch ($class) {
                case 'XenForo_ControllerPublic_Thread':
                    $extend[] = 'SomeClass_ControllerPublicThread';
                    break;
            }
        }
    }
    
    ControllerPublicThread.php
    Code:
    class SomeClass_ControllerPublicThread extends XFCP_SomeClass_ControllerPublicThread {
        ... functionality to override here
    }
    
    Then add the entry in the Code listeners class and refer it to an addon. If you haven't created one, make one.
     
    gginni likes this.
  7. gginni

    gginni Active Member

    Thanks for telling bro :)... I will surely look at how to create add-ons and will soon start creating add-ons :)
     

Share This Page