Closed (works as designed)
Project:
Views PHP Filter
Version:
6.x-1.0-beta1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 Aug 2010 at 14:36 UTC
Updated:
4 Jan 2012 at 13:23 UTC
I try to return the node under the term id, and limit to 2 only. I tried this code with specified term id "642" which works
$args = '642';
$nids = array();
$myquery = db_query("SELECT nid FROM {term_node} WHERE tid = %d LIMIT 2", $args);
while ($row = db_fetch_array($myquery)) {
$nids[] = $row['nid'];
}
return $nids;
However when I tried to pass the URL argument to this filter, as shown below.
$args = arg(2);
$nids = array();
$myquery = db_query("SELECT nid FROM {term_node} WHERE tid = %d LIMIT 2", $args);
while ($row = db_fetch_array($myquery)) {
$nids[] = $row['nid'];
}
return $nids;
It does not work. Is this some functional limitation of this module. Can anybody advise if there is any other workaround. Thanks.
Comments
Comment #1
noemed7 commentedSame problem here, I've created a function that uses a parameter, I use this function in Node: PHP filter as it follows:
return my_function(arg1);
The url is node/222 and the function gets a 0 instead of 2222.
Please how can I solve this.
Thanks in advance
Comment #2
Arkrep commentedThis worked for me ...
Comment #3
gnassar commentedThe arg() function has never been available within a view. Has nothing to do with Views PHP Filter. See Views issue #388024: Arguments from path not available to Views?!.
You can try setting up arguments in your view and using %1, et al., as is suggested in that link.
Otherwise, you can pull the arguments from $view->args like Steven Wilson did above.
Steven: you may want to try that %1 approach -- I don't actually know that it'll work this early in the loader process, but if it does it'll save you that expensive view load in the first line. Let me know if that works for you.
Comment #4
Makku01 commenteddid this work out? are there any experiences with this approach in php-filter?