• 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?

Mythotical

Well-known member
#1
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.
 

Jeremy

Well-known member
#2
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.
 

Mythotical

Well-known member
#3
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.
 

Jeremy

Well-known member
#4
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.
 

Jeremy

Well-known member
#7
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.
 
R

ragtek

Guest
#9
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.
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
 
R

ragtek

Guest
#11
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?
 

Shadab

Well-known member
#15
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.
 

Mythotical

Well-known member
#16
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.
 

Shadab

Well-known member
#17
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?
 

Jaxel

Well-known member
#18
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?
 

Jaxel

Well-known member
#20
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?