That would be a pain. I already have all the extended fields setup in the login process. There's got to be a way. why's it awkward?
Everything I know I learned on the internet. Saved me thousands in College tuition,
-
☆ A M B ☆
- 24,524 Posts
Because they are in a JSON array, and have to be parsed to be usable. I'll figure something out.
As far as a query goes, I think they can be treated as a string (I could be wrong), so you might be able to use LIKE. I'm pretty sure this works:
$c->where(
array(
'Profile.extended:LIKE' => '%'. 'searchstring' .'%',
)
);
-
☆ A M B ☆
- 24,524 Posts
We're not searching on the extended fields, the extended field is for a bio description. It just needs to be extracted for the display.
I'm surprised that pdoUsers doesn't have a &useExtended property. It shouldn't be difficult to add.
Something like this at the proper location:
if ($useExtended) {
array_merge($fields, $profile->get('extended'));
}
Quote from: BobRay at Nov 16, 2014, 04:56 PMI'm surprised that pdoUsers doesn't have a &useExtended property. It shouldn't be difficult to add.
Bob, we've steered away from using pdouser. Here's the code that calls the user info. I need to call the users extended info in the select array.
$c = $modx->newQuery('modUser');
$c->leftJoin('modUserProfile','Profile');
// add column names that u want to show
$c->select(array(
'modUser.*',
'Profile.fullname',
'Profile.city',
'Profile.zip',
'Profile.email',
'Profile.phone',
));
$c->where(array(
'Profile.fax:=' => '0000000000',
'AND:Profile.zip:IN' => $zipArray,
));
$users = $modx->getCollection("modUser",$c);
$output = '';
// use a chunk tpl for formatting the output
// all retrieved user and profile fields will be placeholders
foreach($users as $user){
if($user->isMember('theGroup')) {
$userArray = $user->toArray();
$output .= $modx->getChunk('listTpl', $userArray);
}
}
return $output;
}
Everything I know I learned on the internet. Saved me thousands in College tuition,
Try this. Leave out the join line and do this instead of getCollection():
$users = $modx->getCollectionGraph('modUser', '{"Profile":{}', $c);
$output = '';
foreach($users as $user){
if($user->isMember('theGroup')) {
$userArray = $user->toArray();
$userArray = array_merge($user->Profile->toArray(), $userArray)
$userArray = array_merge($user->Profile->get('extended'), $userArray);
$output .= $modx->getChunk('listTpl', $userArray);
}
}
You should be able to use placeholders for all user, profile, and extended fields.
-
☆ A M B ☆
- 24,524 Posts
I've added the Profile.extended to the original query:
$c->select(array(
'modUser.*',
'Profile.fullname',
'Profile.city',
'Profile.zip',
'Profile.email',
'Profile.phone',
'Profile.extended',
));
and it does in fact return the JSON extended string if [[+extended]] is used in the output chunk. However, [[+extended.userBio]] doesn't work (duh! of course not!), so in the loop I need to pull out the userBio data and insert it into the $userArray.
Just slow going for now, as the autumn storm weather over the last several days has me wheezing and coughing when I'm not sleeping or drugged into near-insensibility.
-
☆ A M B ☆
- 24,524 Posts
Looks like I should be able to convert the JSON string to an array, then array_merge it with the $userArray to give the option of having other values in the extended field as well.
foreach($users as $user){
if($user->isMember('theGroup')) {
$userArray = $user->toArray();
$extendedArray = $modx->fromJSON($userArray['extended']);
$userArray = array_merge($userArray, $extendedArray);
$output .= $modx->getChunk('listTpl', $userArray);
}
}
[ed. note: sottwell last edited this post 11 years, 10 months ago.]
-
☆ A M B ☆
- 24,524 Posts
Wow! Looking at all of the data that's being put into that extended field, in my opinion this is a prime candidate for BobRay's ClassExtender and making a full extended User out of this. There are literally dozens of extended field items, and I can see many of them that will be search criteria.