Passing Variables Between Modules /or/ Windows

Your code modifications and patches you want to share with others.
Locked
alonk
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Nov 02, 2007 2:03 pm

Passing Variables Between Modules /or/ Windows

Post by alonk » Fri Nov 02, 2007 2:14 pm

Is it possible to click on a link in one module and have it load content in a different module?

Or why can't modules be hacked to load content inside themselves?

Do modules like "Featured Articles" always have to load the article into the mosMain content area?



Here are some uses:


1)  Clicking on a link in Recent FAQs (user5) opens up the Faq content in (user6)

2) Clicking on a link in a Wrapper, closes the wrapper and loads a component instead

3) Filling in a poll in User5, the vote button shows the results in User6

verbwit
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sat Mar 22, 2008 1:15 am

Re: Passing Variables Between Modules /or/ Windows

Post by verbwit » Fri Jul 24, 2009 2:17 am

I was wondering the Exact same thing, Any Ideas anyone?

sparkydog
Joomla! Apprentice
Joomla! Apprentice
Posts: 46
Joined: Tue Oct 17, 2006 9:42 pm

Re: Passing Variables Between Modules /or/ Windows

Post by sparkydog » Fri Jul 24, 2009 4:58 am

These are advanced coding questions that you need intermediate to advanced coding skills for and a deeper understanding of the Joomla framework.

The reason that function calls from modules normally pass to the mainbody content area is that these calls are to functions defined in the main controller for the component, and such functions change the content in the mainbody area where the component displays. The display area for modules is not covered by the controller for the component under normal conditions.

But those are the php functions defined in the component. That does not mean one can't use JavaScript to access the DOM to find the other module and make a change in it. In fact some components do almost something like that -- off the top of my head I can think of Mosets Tree which reflects the position in the directory in the mainbody area in an adjacent module which shows a folder tree of where you are in the directory hierarchy -- and THEN, you can click on that folder tree in the module and change your position in the directory in the mainbody component area (I think there's Ajax involved in this too).

There is no reason you can't access another module the same way, except that the DOM would change with every change of module position, so you would have to be careful how that was coded and that the site was set up consistently.

To click on a link in a wrapper and show the component, load the component to where you want, copy the link, and then put that link in the page that's wrapped -- if you have access to that, which often times you don't, which is why you're wrapping another site or something like that. But you can put the link close nearby, above or below or left or right in a custom module position, or in a menu.

Question 3 is the same as question 1.

Plugins may be possibly be designed for certain uses here -- that's another abstruse topic.

I would only add that while these are interesting questions from a programming challenge point of view, I wonder how often this would be required or how much aid this is to the user. I don't know that I would care to load the result from an action on one part of the page to the opposite side of the page, or further up or down. I would think that for the sake of the user and to keep things clear, that in most cases I would want the result to load into the same or adjacent area -- or, to simply make a change in mainbody, where most people expect the content to be reflected. This is the accepted paradigm, and for good reason, which is to not make people dizzy. Information popping up in unpredictable places does nobody any good.

Keeping the result in the same module position might be done with JavaScript and Ajax, and if the area expands as a result, then so be it. People are used to that. You can put more than one module in any module position, also. For example, the left and right columns are standard structure that go back to the printed page. In most templates, there's one column on either side you can use, and you can easily make your result appear there since it is essentially in the same place.

Another option is to design the view of the component so it looks like there's another "module" position. You could take up the whole page with the mainbody if you want, and create a grid with a left or right column or even above or below that, when a link is clicked in it, a change occurs in the same place or even another place nearby. It's all in the component, though, not in the a module.

So these are interesting things to ponder, and you've got me thinking.....


Locked

Return to “Core Hacks and Patches”