I have a function in my custom module that return the nids for drafts in array.

function get_all_drafts(){
    $query = db_query("select bid from kom_draft");
    $res = $query->fetchAll();
    foreach($res as $bid){
        $output[] = $bid->bid;
    return $output;

and following code is used in contextual filter nid ( php code text area )

$nids = get_all_drafts();
return implode('+',$nids);

and checked the multiple value checkbox but its not working, i checked the query and there in not value to compare.

when i use the same code on tpl file i am getting proper output that is + separated nids.

  • Could you add some devel call for getting value of $nids before you return the imploded string? E.g. $nids = get_all_drafts(); dpm($nids); return implode('+',$nids); Commented May 27, 2016 at 5:04

1 Answer 1


I just get it done by enabling validation criteria, I selected content validation with node content type and its working fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.