1

Are any tokens(as nid) available in the FILTER CRITERIA of Views (see pic bellow). For example I can sort out all nodes with greater than the current NID...

enter image description here

  • have you tried to use contextual filters? – Aboodred1 Apr 13 '13 at 22:30
  • been thinking how to do it with contextual filters but haven't figured it out yet? any advise ? :) – Ivan Ivanov Apr 13 '13 at 22:37
  • you want to exclude the current node or keep it? – Aboodred1 Apr 13 '13 at 22:41
  • exclude the current and show up 3 or 4 with the same type and greater nid – Ivan Ivanov Apr 13 '13 at 22:42
2

I don't see any way in the Views UI to do this, but you certainly can with a hook:

function YOURMODULE_views_pre_view(&$view, &$display_id, &$args) {

  if ($view->name=='THE_VIEW_YOU_ARE_LOOKING_FOR' && ($node=menu_get_object())) {

    $filters = $view->display_handler->get_option('filters');

    $filters['nid']['value']['value'] = $node->nid;

    $view->display_handler->override_option('filters', $filters);

  }

}

which would set the value in the node nid filter to that of the node nid the View is displayed on.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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