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

load_class_route_prefix: "Cannot load class using XFCP. Load the class using the correct loader fir

Discussion in 'XenForo Development Discussions' started by Marcus, Jul 17, 2013.

  1. Marcus

    Marcus Well-Known Member

    I want to add a "&node_id=..." to my virtual forums.


    This is the class (the editor here does not keep tabs from my windows notepad as well as eclipse):
    PHP:
    <?php
    class VirtualForums_Route_Prefix_Threads extends XFCP_VirtualForums_Route_Prefix_Threads
    {
    public function 
    buildLink($originalPrefix$outputPrefix$action$extension$data, array &$extraParams)
    {
    $response parent::buildLink();

    if(isset(
    $response->params['data']['myforumId']))
    {
    $response->params['extraParams']['node_id'] = $response->params['data']['myforumId'];
    }

    return 
    $response;
    }

    }
    screenshot.JPG
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    Marcus likes this.
  3. Marcus

    Marcus Well-Known Member

    OK sure its a listener. Where would you put in the listener for this class?
    In VirtualForums/Prefixlistener or in VirtualForums/Route/Prefix/Listener ?
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    You can place it wherever you want, just make sure the listener class is properly named, that the function is static, and that you assign it in the event listener.
     
    Marcus likes this.
  5. Marcus

    Marcus Well-Known Member

    I know, but is there a common practice for naming listeners according to what they are listening to?
     
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    No. My general practice is:

    Addon_CodeEvent_Listener::eventName()
     
    Marcus likes this.
  7. tyteen4a03

    tyteen4a03 Well-Known Member

    Mine is: Things_Listeners_LoadClasses::eventNameHere(_eventHint) or Things_Listeners::eventNameHere(_eventHint).

    I would use Things_Listeners_eventNameHere::fire(_eventHint) for a lot of code, but I haven't had this need yet.
     

Share This Page