Blocks and service calls

Events happening in the community are now at Drupal community events on www.drupal.org.
Fixdit's picture

It seems that node specific data (nid, title) isn't getting passed into a block I have that contains a SWF looking to call a "views.getView" service. The view contains an argument that looks for a node ID and shows only that nodes info.
I've got a custom page layout in Panels2. One of the panels holds this service calling SWF. It seems that the block or SWF itself isn't registering an nid, where as other views and pieces of content in the same panel do?
Is there a snippet or workaround to pass the data needed into blocks for the service call to use?

The type of argument handling I'm using in the view at the moment is:

global $node;
// Make the first argument the current node if not already set
if (!$args[0]) {
  $args[0] = $node->nid;
}
  1. My "views.getView" service in the services browser works when I pass it a node ID
  2. My SWF calls a view like "frontpage" and displays data (but this doesn't rely on the current nodes ID to work)
  3. Other content in the panel (which isn't a block) is picking up the the nid for it's arguments.

Comments

change your arguments

bmcmurray's picture

If you want the NID of the node a block is on to be passed to views, set the following in the Argument Handling Code of your view:

$args[0] = arg(1);

B.McMurray

B.McMurray

This returns a NULL value

Fixdit's picture

$args[0] = arg(1);
This returns a NULL value in the service response. This means I think that nid isn't getting passed in time.
Here is the problem and what I need to achieve in more broad terms:
I have a view which relies on a node ID argument. This basic arg looks like this:

if ( arg(0) == 'node' && is_numeric(arg(1)) && ! arg(2) ) {
$node = node_load(arg(1));
}

I have an SWF I want to utilise this view. The currently viewed node's 'nid' needs to be passed to a "views.getView" service in Flash. The argument doesn't seem to register the information and returns a NULL result. Is there a better way to display such a view through services? Would it be better to do something with the node.load service instead?
Thanks for the input.

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: