Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.2
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 Feb 2009 at 18:02 UTC
Updated:
6 May 2009 at 17:50 UTC
I have a view that requires a nid as an argument.
When the argument is not provided, I'm using custom php code to set it up.
My code:
if (isnumeric(arg(4)){
$id = arg(4);
}
elseif (arg(0) == 'node' && isnumeric(arg(1))){
$id = _myModule_custom_function(arg(1));
}
return $id;
Explanation:
I use this view on 2 pages, on the first one the nid is in arg(4), on the second page, it is a different node and the custom function finds the appropriate nid for the view.
My question:
can I use custom functions in this php block to determine the return variable?
If so, anyone sees an error in my code? (the custom function returns the right nid)
Comments
Comment #1
merlinofchaos commentedYou can use custom functions, but if you're going to do this you probably should just create a full plugin and not split your code up like this. It's only a little extra work to create a plugin and I think will be worth it.
Comment #2
thijsvdanker commentedThanks works like a charm!
As this is part of the todo on the advanced help page for views I figured it might be worth sharing my solution.
in myModule_views.inc:
in myModule_plugin_argument_default_node.inc
Comment #3
dawehnerso thx! for providing your solutionn.
this can be marked as fixed now!