I need often to exclude (or limit to) a custom list of nodes from a view. I used to enter the PHP logic directly in the php argument code text area, but this is getting difficult to mantain. I would like to store the logic in a module or template.php.
What I need is a general approach for returning a list of nids (nid1+nid2+nid3...) in the php argument code of the view. I have tried using the approach described here, but I can make it work only for block displays, not for page displays.
For example, I have a content type where nodes can arbitrarily be restricted to authenticated users using the Content Access module per-node settings. I need to display in a view only those nodes, excluding the ones that are visible to the anonymous users. Since there is no filter for this in views, I have built a simple function to retrieve the node IDs and store them in a variable (nid1+nid2+nid3...).
I am struggling to find out where to put this logic (
mymodule_preprocess_func(), etc.) in order to be able to use this variable in any view PHP argument code.
TL;DR: I need a general approach for returning a list of nids (nid1+nid2+nid3...) in the PHP argument code of the view, saving the php logic in a module or theme.