Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Using MetaMod variables in other modules

Using MetaMod variables in other modules

Hi.  Wonderful module you have here!  Lot's to use it for.  Thank you!

My question is:

I am trying to access the $geo->latitude and $geo->longitude variable output in the Sobi2 Geo Category Overview Module that displays a Google Map with those variables that are entered from the module admin area.  I'd like to hardcode the geoip variables that are found from the metamod code that appears on my page.  I have tried to include all of the files in your module right from the mod_sobi2gcat.php file and still can't get those variables to load.  Any quick and easy way to pull those variables across modules via code?  Thank you!

akhanukov
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Using MetaMod variables in other modules

Hi Akhanukov,

If you would normally enter the long and lat variables as static text in the module admin area for the "Sobi2 Geo Category Overview Module", then you can probably do it this way:

You can get MetaMod to dynamically set module parameters of the modules that it is including.

e.g. if there's a parameter in the "Sobi2 Geo Category Overview Module" called "latitude", and one called "longitude", then you can set these from inside MetaMod like this:

$module_to_display = 101; /* replace with the SOBI2 module id */
$changes->mod($module_to_display)->setParam("longitude","some longitude number...")->setParam("latitude","some latitude number...);
return $module_to_display;

You would probably need to work with the formatting of the GeoIP location variables from MetaMod to sub into the code snippet above.

Now, it's quite possible that "Sobi2 Geo Category Overview Module" does not use parameters like this. In that case it's not going to be possible to use that method.

You should be able to dissect MetaMod to find out how the GeoIP stuff works though...

It sounds like you are essentially trying to use "Sobi2 Geo Category Overview Module" as a generic mapping tool, that puts a marker into the location where the user is connecting from, right?

If that's the case then you might be able to find other Google Map modules that *do* take a longitude and latitude parameter, that you can control from MetaMod as suggested above.

Hope that helps...
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod variables in other modules

Stephen,

Thanks for the quick response!  I will try these techniques this evening and let you know how it went. Thanks!

- Alex

akhanukov
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Using MetaMod variables in other modules

I'm about to try out the fix but having reread your response I wanted to clarify a bit more.

I'm using Metamod to figure out what a user's location is.  What is important to me is mostly their zip code/postal code since the site is really a directory built in SOBI2.  I'd like a user to open up the homepage and have the map centered on their location based on that zip, but I can use latitude and longitude, which Metamod also displays.

However, the module I'm using to display a google map, SOBI2 Geo Category Overview Module has many cool features including custom icons and editable bubbles that make it a great plugin to the SOBI2 Directory.  Unfortunately, the way the map is generated, it needs the latitude and longitude, which is ok too since that's available.  My issue, is that I'm trying to pull your metamod output variables or even the output itself and create new or replace the latitude and longitude variables with your data (generated on page load) rather than what is normally entered as the center point in the module's back end.

I was just under the assumption that I would have to include your files from that module and call those variables but I wasn't able to make them work, even as globals. The solution you posted makes me think I didn't explain the problem as best I could.  I will try it nonetheless and hope for the best.  Thanks for your help!

- Alex

akhanukov
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Using MetaMod variables in other modules

So, in the SOBI2 Geo Category module, what sort of parameters do you set for this "center point"? Does it try to determine this itself based on the info in the SOBI2 entries, or is it just a text box (or 2) where you give it a long/lat for the center point?

If it's just a text box then you can use something like the code I suggested earlier.

If it's not, then you will definitely need to edit the code within the SOBI2 Geo Category module, and it sounds like you're willing to attempt that.

I think that the easiest way to pass in those variables from MetaMod would actually be to use the code that I suggested earlier, even if those parameters are not directly used in SOBI2 Geo Category module. Because then, they are really easy to retrieve inside the other module. If the parameters in SOBI2 Geo Category module are in a variable called $params, then you can just say:

$lat = $params->get("latitude_from_metamod");
$long = $params->get("longitude_from_metamod");

... then you can use these however you like.

The corresponding code in MetaMod, to pass these through to the other module, would be:

$module_to_display = 101; /* replace with the SOBI2 module id */
$changes->mod($module_to_display)
  ->setParam("longitude_from_metamod", $geoip->longitude)
  ->setParam("latitude_from_metamod", $geoip->latitude);
return $module_to_display;


Hope one of those approaches will work!
Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Using MetaMod variables in other modules

Stephen,

It Worked!!!

I'm sorry.  I was totally misunderstanding and underestimating the power of MetaMod.  I researched your site a bit and found this page: http://www.metamodpro.com/support/contr … parameters

Once I figured out how parameters worked, I just started over and the implementation was wayyy simpler than what I was trying.  I was also using MosModule when I didn't really have to, so I just created the Sobi2 Geo Category Overview Module, set the "show on" to None, then created the MetaMod, added the code (and tweaked it) to my module ID and all worked perfectly.  Now I'm "regionalizing" my entire site since I have realized the power of this module!!  Thanks again!  Please mark it SOLVED! smile

- Alex

P.S. Merry Christmas and Happy New Year!

akhanukov
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Using MetaMod variables in other modules

Hi Alex, Happy New Year to you too!

Your solution sounds great!

Can you give any more details about what parameters you are setting in the Sobi2 Geo Category Overview Module? i.e. are there existing parameters in there that MetaMod was able to alter directly, or did you just set some arbitrary parameters with MetaMod, then wrote some of your own code in Sobi2 Geo Category Overview Module to pick up these parameters and use them to set the map centre?

This parameter-setting capability of MetaMod is enormously powerful. I helped one guy reduce the number of modules on his site from about 1000 to just 8 (plus 8 MetaMods). He had essentially created a directory of different sports teams using articles, 1 per menu item. On each page he had 8 modules, which were RSS feeds, Twitter searches and news searches for the name of the team. Managing all of these was a nightmare... 8 individual modules on each page, all individually set and assigned to the correct menu item.

So we made 8 "template" modules, controlled by 8 MetaMods. Each MetaMod detected the name of the page that it was placed on, then used that to set the text of the "search" parameters of its corresponding RSS/Twitter module, then included that module into the appropriate module position.

Now all he has to do to add a new page is... add a new page with the name of the sports team as the page name. All the modules then automatically appear with the correct parameters based on that name. If he ever wants to change the look and feel of the modules, he only needs to tweak the 8 "template" modules, and these are reflected across the whole site.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1698
Total Polls:
6
Total Posts:
5944
Posts this week:
4
User Info:
 
Total Users:
5544
Newest User:
odom3140505
Members Online:
1
Guests Online:
141

Online: 
odom3140505

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked