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

Code Event Listener - Tutorial Possible?

Discussion in 'XenForo Development Discussions' started by Mythotical, Nov 25, 2010.

  1. Mythotical

    Mythotical Well-Known Member

    Is there a tutorial available that shows how to use each code event listener as it is meant to be used? I think a tut of it would save me a lot of questions and confusion.
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    Code Event Listeners are basically used to extend classes, through the $extend[] = 'Your_Class_Here'; I really see nothing else as being what they are used for.
     
  3. Mythotical

    Mythotical Well-Known Member

    I know that I meant a tut for how they are built such as:
    PHP:
    class XXX
    {
    public function 
    Blah (&$params)
    {
    $this->fake();
    }
    private function 
    BeBlah
    {
    $this->alsoFake();
    }
    }
    Not really how to use them but how the file should be built.
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    I'm confused on what your asking. If your class is meant to tie in / overwrite functionality, it always extends XFCP_yourclassname. And XenForo sets the correct class. The structure depends on what you want to do. What ARE you trying to accomplish that you aren't grasping how to set up our file?

    It you want examples go and download any of my add one as they all (except shorten URL) make use of this. SFS extends the register controller, overwrites a function to perform validation, then sends it back to XenForo. BB Code Manager extends a function to define a variable for a template.
     
  5. Mythotical

    Mythotical Well-Known Member

    The one code event I'm trying to grasp is the FrontController_Pre_View

    But I will take a look at your addons for sure.
     
  6. Mythotical

    Mythotical Well-Known Member

  7. Jeremy

    Jeremy XenForo Moderator Staff Member

    I'm unable to help you with more than theory at the moment, but my suggestion is to look at a class that'd be extending there, and see what methods, variables, etc. are available.
     
  8. Mythotical

    Mythotical Well-Known Member

    I've attempted that already but got more confused than anything. *sigh*
     
  9. ragtek

    ragtek Guest

    No, they are not only used for extending;)

    They are also used to "include" own vars into classes (for example navbar, visotor setup,..)
    I'm also using a own code event, for a interface for 3rd party developers, to be able to include own classes in the forumconnector
     
  10. Mythotical

    Mythotical Well-Known Member

    Am I the only one that doesn't have a full grasp on this code event listener stuff? LOL
     
  11. ragtek

    ragtek Guest

    It seems so:p That's not nice, that somebody who want to sell commercial mods have no clue:p *scnr*

    What's exactly your problem?
     
  12. Mythotical

    Mythotical Well-Known Member

  13. Jeremy

    Jeremy XenForo Moderator Staff Member

    Ragtek, injecting my own variables and such to me is extending.
     
  14. ragtek

    ragtek Guest

    ok^^
    i thought you mean the way, xenforo is extending the "dynamic/proxy classes"
     
  15. Shadab

    Shadab Well-Known Member

    Steve, can you tell us what exactly you are trying to do?

    From what I can understand, you want to fetch the latest threads (globally, or on a per-node basis) and display them in a separate "portal" page. If that's it, you don't need to use the "front_controller_pre_view" event listener. A model, a view, a controller and a registered route prefix is all you need.
     
  16. Mythotical

    Mythotical Well-Known Member

    Shadab, I want to fetch the latest threads of all forums and by node id that I specify. Exactly how can I do that and avoid the event listener? The thread list will display in a block on my portal page.
     
  17. Shadab

    Shadab Well-Known Member

    I have a feeling your View file (xPortal_ViewPublic_Portal) is at fault. You are creating template objects (via the createTemplateObject() method) but not passing them any parameters.

    If possible, can you send over the complete source for your mod (via PC) so I can look closely?
     
  18. Jaxel

    Jaxel Well-Known Member

    Is it possible to extend a ViewPublic class?

    Normally I would make you would make your own ViewPublic class, but in this specific case, thats not an option and I need to extend onto the existing one. Is something like this possible?
     
  19. Shadab

    Shadab Well-Known Member

    Yes! Create an event listener for the "load_class_view" event.
    And extend the View class just like you would extend a Controller or a DataWriter.
     
  20. Jaxel

    Jaxel Well-Known Member

    Okay, I couldn't get "load_class_view" working... but lets move on, I figured out a different way to do it what I was trying to do...

    My next quesiton... I used "load_class_controller" to add stuff to the ThreadView, including an input form:
    Untitled-1.png

    My next question sounds like it would have a simple answer, but I'm lost... With my input form:
    • where should I be sending the form action and how do I control it?
     

Share This Page