Skip to main content
Better explained
Source Link

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 whenin another context. When viewing thata 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;
}

But even ifSuppose I manage tocan get the viewnodes shown on the "lasts" views programatically, this. Then what? This approach will only work to filter out a single node, not the three I'm getting onI'll get from that view.

SomeAny ideas?

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 when viewing that node, choosing «Provide default value» with some PHP code combined with the option «Exclude».

$node = menu_get_object();

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

But even if I manage to get the view programatically, this will only work to filter out a single node, not the three I'm getting on that view.

Some ideas?

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?

Source Link

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 when viewing that node, choosing «Provide default value» with some PHP code combined with the option «Exclude».

$node = menu_get_object();

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

But even if I manage to get the view programatically, this will only work to filter out a single node, not the three I'm getting on that view.

Some ideas?