I'm attempting to use pdouser with the &where statement to filter them. A user must have "0000000000" and "Member" and any of the zip codes. What I show here is not working and I'm unable to find any docs on the &where statement.
[[!pdoUsers?
&tpl=`userListTpl`
&where=`{"AND:modUserProfile.fax:=":"0000000000",
"AND:modUserProfile.comment:=":"Member",
"OR:modUserProfile.zip:=":"83206",
"OR:modUserProfile.zip:=":"83209",
"OR:modUserProfile.zip:=":"83201"}`
&limit=`0`
&useExtended=`1`]]
Everything I know I learned on the internet. Saved me thousands in College tuition,
This might help:
http://rtfm.modx.com/xpdo/2.x/class-reference/xpdoquery/xpdoquery.where
If you have an editor that can run PHP, you can write it as an array, then do this to get the string to use in the &where property:
echo json_encode($myArray);
or in a MODX snippet:
return $modx->toJSON($myArray);
-
☆ A M B ☆
- 24,524 Posts
Once you get the list of zipcodes into an array, this code will display what you want:
$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;
}
Quote from: sottwell at Nov 15, 2014, 11:21 AMOnce you get the list of zipcodes into an array, this code will display what you want:
$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;
}
Does this go in that other snippet findZip? I had to fiddle with it to keep the project moving forward.
Everything I know I learned on the internet. Saved me thousands in College tuition,
-
☆ A M B ☆
- 24,524 Posts
Yes. It's in place and working. I just need to know what you want to do.
If you look at snippet and index.php?id=20 you'll see what I need. But I can't get the snippet to filter the users at all. I'll also want different levels of information based on whether the user is logged in as a rider or not. I would imagine that would be a basic if statement. I won't mess with anymore if you can take it look at it.
Everything I know I learned on the internet. Saved me thousands in College tuition,
-
☆ A M B ☆
- 24,524 Posts
Should be working now. Just need to add some output modifiers to the tpl chunk to show the extra info to logged-in users.
Ha! I messed with that thing all afternoon trying to figure it out. Grrrrrrr! Thanks!
$c->select(array(
'modUser.*',
'Profile.fullname',
'Profile.city',
'Profile.zip',
'Profile.email',
'Profile.phone',
));
In this section how do I pull from the extended fields?
Everything I know I learned on the internet. Saved me thousands in College tuition,
-
☆ A M B ☆
- 24,524 Posts
That's awkward. Perhaps use the Comments field instead?