[support] Passing multiple values into a single Views argument

Idan Arbel idan at arbel-designs.com
Sat Nov 20 13:30:55 UTC 2010


Take a look at this code I used for something similar:

 

if (arg(0) == 'node' && is_numeric(arg(1))) {
$node=node_load(arg(1));
$term = taxonomy_node_get_terms_by_vocabulary($node, 4); // 4 being the
vocabulary id
$terms = array_keys($term);
$args[0] = $terms[0];
for($i=1; $i<count($terms); $i++)
$args[0] = $args[0] ."+" .$terms[$i]; // replace the + with , if you want
and "And" action instead of "or"
}
return $args[0];

 

might help you out.


Idan

 

From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Neil Coghlan
Sent: Saturday, November 20, 2010 3:25 PM
To: support at drupal.org
Subject: Re: [support] Passing multiple values into a single Views argument

 

Idan, I only just realised myself there was an "accept multiple arguments"
checkbox....without that, I never would get it working!

so...now with that checked, I still need to get the UID's passed in x,y,z or
x+y+z format.

On 20/11/2010 10:21, Idan Arbel wrote: 

if you want to view to take them into account as using "AND" then return
them like so: 12+32+34, if you want it to take them into account as or
return them as so 12,32,34. 

 

don't forget to check to box in the argument settings area to accept
multiple arguments

On Sat, Nov 20, 2010 at 3:14 PM, Neil Coghlan <neil at esl-lounge.com> wrote:

I have a view where I have selected User:uid as an argument and I am
using a sql query in the "Provide Default Argument" part. The problem
is, usually, the sql query is passing muliple UIDs back. How would I
pass all of them into the argument to be used by the view.

At the moment, the view is only taking the first one.

so, here is a simplified version of my php code:

global $user;
$result = db_query("SELECT node.uid FROM {node}
WHERE node.type = 'profile'");
$member = db_fetch_object($result);
return "$member->uid";

on my current db, this returns 3 UIDs...the view only takes the first one.

Thanks

Neil


--
[ Drupal support list | http://lists.drupal.org/ ]

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20101120/fcd15829/attachment.html 


More information about the support mailing list