views:

604

answers:

2

Hi,

I'm using module_invoke() to include a block and I need in this block to read a value contained in my parent content type page. So how can I get the $node variable in my block from the view?

Code I'm using:

<?php
    $block = module_invoke('my_blocks', 'block', 'view', 7);
    print $block['content'];
?>

Now I need to access $node in "my_blocks" and the variable is empty. What can I do to get it?

Thanks a lot for any help!

Regards

A: 

I think the context module or chaos tools can help with that, but here's how I did the same thing recently:

function myModule_get_current_node() {
    $path_arr = explode('/', $_GET['q']);
    if ($path_arr[0] == 'node') $result = node_load($path_arr[1]);
    else $result = null;
    return $result;
}
sprugman
A: 
Nikit
menu_get_object() will save you a bit of typing if you're using Drupal 6 and up.
jhedstrom
ah, of course...
Nikit
Thanks to both of you, it did the trick!
Wickramben

related questions