Page 1 of 1

Events and Modules

Posted: Tue Aug 28, 2007 4:54 am
by uweD
Hi,

Another question slightly related to my other post:

Can I register a module for an  event in the same way as I register plugins for events?

What I would like to achieve is building a navigation bar which updates itself when an event gets triggered by the component.

Or: Is there a possibility that a plugin can update a component?

Cheers,
Uwe

Re: Events and Modules

Posted: Tue Aug 28, 2007 10:32 pm
by tjay
I know folks have used Moofx in modules. So without knowing a great deal more than that I am not sure.

Re: Events and Modules

Posted: Tue Aug 28, 2007 11:15 pm
by ianmac
Modules can certainly registered code to handle events.  But I don't think this is what you want to do.

A module gets called at load time, so presumably it would operate on the latest data produced by the module anyway, so that seems rather pointless...

I think what you are trying to do, as tjay suggested, is to use mootools or some sort of Javascript to trigger an update.

Ian

Re: Events and Modules

Posted: Tue Aug 28, 2007 11:37 pm
by uweD
Hi Ian,

I am simply struggling with understanding the joomla! framework properly. You see, what I am trying to do is.

1. My component performs a search.
2. My module presents the user with a navigation bar to navigate through the search result.

To do this (I believe) I need to create an event, and something that listens for an event and then updates my module...

I start to believing that this might be impossible in Joomla!


Thanks,
Uwe

Re: Events and Modules

Posted: Wed Aug 29, 2007 1:28 am
by ianmac
Okay...

That is pretty simple...

There are options on how to accomplish it:
The first option is to create a Search plugin for the Joomla! search component.  Look at the plugins in the search directory for examples.  This might save you from writing some of the login in your component.

The other option is to incorporate the search as part of your component.  This is the method you seem to be trying to pull off.  You're stuck trying you to present your navigation bar in your module.

My impulse would be to include the navigation bar as part of the component itself.  Problem solved.  You seem to want to separate it and put it into a module.  I'll assume you have a good reason to do this, but I can't think of what that might be.  It is of no consequence, really...

Since your navigation bar is in the module, it is really the module that has to update the component, probably not vice versa.  But they don't really have to communicate.  You'd probably have in your module an HTML form of some sort, right?

Your component will determine which page to display based on the form variables (or you may possibly be using request variables on the query string).  These are retrieve using JRequest::getInt(), right?

So...  in your module, you determine where the in the result set you are and display the navigation bar appropriately.

As an example, say there are 25 records.  We will use two variables - limit, and limitstart.  limit is the number of results to display per page, and limitstart is the place in the results to start.

Your navigation bar would do something like:
$limit = JRequest::getInt( 'limit' );
$limitstart = JRequest::getInt( 'limitstart' );

based on limit and limitstart it will display the navigation.


Then, the component would contain the same two lines, and based on those numbers will display the result set.

Does this answer your question.
Ian

Re: Events and Modules

Posted: Wed Aug 29, 2007 1:54 am
by uweD
Thanks for that very detailed explanation Ian,

yes that answers my question,

Cheers,
uwe