Skip to main content
2 of 2
Better explained

Avoid duplicates on a view based on results from another view

I have a node type and two views:

  • One displaying the last 3 elements with a field marked as «important».
  • Another with 3 random elements, marked as important or not.

I don't want the views to repeat nodes.

Since the "lasts" views should always display the last 3 important elements, I thought about filtering the nodes on the random view, but I don't know how.

I managed to do it for a single node in another context. When viewing a node, choosing «Provide default value» with some PHP code combined with the option «Exclude», I can manage to hide that node from the views.

$node = menu_get_object();

if (isset($node->nid)) {
   return $node->nid;
}
else{
  return 0;
}

Suppose I can get the nodes shown on the "lasts" views programatically. Then what? This approach will only work to filter out a single node, not the three I'll get from that view.

Any ideas?