use "php code" in page manager access rules to evaluate if current og_group has content of a specific type I'm grateful for the amazing organic groups module (and so many other drupal modules), which I am using for a civil society and social economy network platform.

I have a question, which I think would be interesting for others too. I couldn't find the answer anywhere.

Usecase: I have a page (in page manager) which outputs a tab in og_group nodes, showing a view panel pane of og_group content (together with other panes). Specifically, og_group are organizations, and og_group contents are events. So I'm showing events of each organization in a separete tab.

I wish this tab "events" to be visibile only if there is at least one node of type "event" listed as group content of the og_group page being viewed.

In order to do this, I am trying to use page manager "access rules", which, to quote specific documentation:


  are used to test if the page is accessible and any menu items
  associated with it are visible.


The "only" og related rules available are:


  "Node is an OG group" 
  "Node is an OG group content" 
  "user membership in group" 
  "user permissions in group"


So, I think my logic is possible with the generic "php code" rule. But I'm no coder, yet.

Anybody could give me a hint about what code should I write to check if te viewed node (which is an OG group) has at least one event associated with it as group content?

Thanks!!!

Config: D7 7.41, php 5.2.4, panopoly 7.x-1.28, og 7.x-2.7, ctools 7.x-1.8, panels 7.x-3.5

Update: as @Stefanos suggested in his answer, I am searching for a kind of "no results" behavior of views module, in page manager.

@Stefanos, here is the context available in the page:
Direct answer: To do this with the code you provided, you should use something like the following:

$node = $contexts['argument_entity_id:node_1']-&gt;data;
$args = array($node-&gt;nid‌​);
return empty(views_get_view_result('rbv_view_group_content','panel_pane_3',$args));


Alternative answer: I have an alternative suggestion, and unless you absolutely want to use the Page Manager, it should allow you to solve your problem without any coding.  

So, if you read so far... :-), I would suggest using Views and setting up a path that will 'link' your view to your group node's URL. You are probably already using a view to list your Events. You can set up a page for that view that has a path like the following:

node/%nid/events


You should further configure your page to be rendered as a "Menu Tab", titled "Events".

This Views Page will now be linked to your Group page, and you will be able to handle its behaviour in the case of no results (Events) for that og_group node; for your case to simply hide it.  

To get this all working, you would also need to set up your contextual filters to use the og_group nid.

This is a bit theoretical, but I am not entirely sure of your setup.
I hope it helps you though!