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

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,
 
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();
        }
 
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.
 
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

      }

 }
 
Top Bottom