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

How to access forum information from within the visitor_setup code event listener?

Discussion in 'XenForo Development Discussions' started by simunaqv, Nov 5, 2010.

  1. simunaqv

    simunaqv Well-Known Member

    Hello,
    I want to access forum information from within the visitor_setup code event listener. Can somebody please tell me how to get a handle to the forum information from the visitor_setup code event listener?
    Thanks,
     
  2. Lawrence

    Lawrence Well-Known Member

    Are you referring to a specific forum id, or the forum (board) in general, and what information are you trying to retrieve? For example to retrieve board totals:

    Code:
            $boardTotals = $this->getModelFromCache('XenForo_Model_DataRegistry')->get('boardTotals');
            if (!$boardTotals)
            {
                $boardTotals = $this->getModelFromCache('XenForo_Model_Counters')->rebuildBoardTotalsCounter();
            }
    
     
  3. simunaqv

    simunaqv Well-Known Member

    Hi Lawrence,
    I want to find out the forum_id of the current forum whenever the user is looking at the list of threads (forum display) or reading a thread.
     
  4. Lawrence

    Lawrence Well-Known Member

    I would create a listener to listen for ControllerPublic_Forum class being loaded using the Load_Class_Listener, and put my code there as you are looking for forum id's.

    Code:
    class MyNiftyAddon_Listener_LoadClassController
    {
            public static function loadClassListener($class, &$extend)
            {
    
                    if ($class == 'XenForo_ControllerPublic_Forum')
                    {
                            $extend[] = 'MyNiftyAddon_ControllerPublic_Forum';
                    }
    
            }
    
    }
    
    Code:
    class MyNiftyAddon_ControllerPublic_Forum extends XFCP_MyNiftyAddon_ControllerPublic_Forum
     {
          public function actionXxxxx()
        {
                  My Nifty code here that checks for the forumid and performs some action
    
          }
    
     }
    
     

Share This Page