Jump to content


Photo

Enhanced custom fields


  • Please log in to reply
No replies to this topic

#1 ryddler

ryddler

Posted 26 September 2011 - 02:26 AM

After following these instructions from another post...

The custom fields are not loaded.

This should work:

Open /admin/applications_addon/other/membermap/sources/classes/google.php around line 111

Find

$data = IPSMember::load($this->_memberIds, 'profile_portal,groups');

Replace with:
$data = IPSMember::load($this->_memberIds, 'profile_portal,groups,customFields');


I discovered that the custom fields on my site only displayed the key for the actual values I wanted to display, because I use several custom fields with drop-down selections to limit choices to specific car models, colors, years, etc. Not to be stifled, I modified the code a bit to pull in the custom fields in the event of drop-downs, and thought I'd share for anyone else that needs to accomplish the same thing.

as in the example above, around line 111, find
		   $data = IPSMember::load($this->_memberIds, 'profile_portal,groups');
 
		  foreach ($data as $key => $val)
		  {
			  $this->_markers[$key]['memberData'] = $val;
		  }

and replace with
			$data = IPSMember::load($this->_memberIds, 'profile_portal,groups,customFields');
			$cf_types = ipsRegistry::cache()->getCache( 'profilefields' );
			foreach ($cf_types as $cfkey => $cfval)
			{
				if ($cf_types[$cfkey]['pf_type'] === 'drop')
				{
					foreach ( explode("|", $cf_types[$cfkey]['pf_content']) as $item)
					{
						$pair = explode("=", $item);
						$cust_field[ 'field_' . $cfkey ][$pair[0]] = $pair[1];
					}
				  
				}
			}
									
			foreach ($data as $key => $val)
			{
				$this->_markers[$key]['memberData'] = $val;
				foreach ($cust_field as $cfld => $cfval_array)
				{
					$this->_markers[$key]['memberData'][$cfld] = $cfval_array[ $this->_markers[$key]['memberData'][$cfld] ];
				}
			}

Now the values the users have chosen in drop-down fields should be accessible using the same 'field_1', 'field_2' etc.

Enjoy!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users