Events and Modules

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
uweD
Joomla! Apprentice
Joomla! Apprentice
Posts: 39
Joined: Mon May 14, 2007 9:38 pm
Location: Auckland -- New Zealand
Contact:

Events and Modules

Post by uweD » Tue Aug 28, 2007 4:54 am

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
Last edited by uweD on Wed Aug 29, 2007 1:54 am, edited 1 time in total.
________________________
Uwe Duesing
http://www.uweduesing.com
Skype:uweOnehunga

User avatar
tjay
Joomla! Intern
Joomla! Intern
Posts: 73
Joined: Thu Aug 18, 2005 1:50 am
Location: New Orleans
Contact:

Re: Events and Modules

Post by tjay » Tue Aug 28, 2007 10:32 pm

I know folks have used Moofx in modules. So without knowing a great deal more than that I am not sure.
This day it is my wish that I helped you to live

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Events and Modules

Post by ianmac » Tue Aug 28, 2007 11:15 pm

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
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

User avatar
uweD
Joomla! Apprentice
Joomla! Apprentice
Posts: 39
Joined: Mon May 14, 2007 9:38 pm
Location: Auckland -- New Zealand
Contact:

Re: Events and Modules

Post by uweD » Tue Aug 28, 2007 11:37 pm

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
________________________
Uwe Duesing
http://www.uweduesing.com
Skype:uweOnehunga

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Events and Modules

Post by ianmac » Wed Aug 29, 2007 1:28 am

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
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

User avatar
uweD
Joomla! Apprentice
Joomla! Apprentice
Posts: 39
Joined: Mon May 14, 2007 9:38 pm
Location: Auckland -- New Zealand
Contact:

Re: Events and Modules

Post by uweD » Wed Aug 29, 2007 1:54 am

Thanks for that very detailed explanation Ian,

yes that answers my question,

Cheers,
uwe
________________________
Uwe Duesing
http://www.uweduesing.com
Skype:uweOnehunga


Post Reply