I have created several content types and using views I have created blocks that take the uid as an argument and displays content that that author has created. So far so good.

What I want to do now is create a module that displays all these blocks in a given area,

I have the HTML ready and I can create a page that passes the markup back to drupal and display that, what I would like to do is populate those areas with the given block.

so for example. If I have a page called:

www.example.com/displayMyContent/58 (where 58 is the user ID)

the HTMl of the page would be online these lines:

$uid = args(2);
$markup = "
<div id="myVideoBlock"> ". drupal_call_to_render_block("MyVideosBlock", $uid). "</div>";


what would be the function to insert the given block into the given section and how would I pass the $uid to the block so that only the authors content would be displayed?

Also there are reasons why i am not using the blcok functions in admin mainly because there will be other blocks added on the page and I need control of where the blocks will be placed

1 Answer 1


I think you may be able to do this by using the global $user variable.

  1. 1 create the hooks block_info and block_view

  2. create hook_theme()

  3. define a theme to be able to pass variables to template.
  4. create the template

in your block_view do something along the lines of this:

    case 'myvideoblock':
            global $user;
            $view = views_get_view('YOURVIEW');
            $result = $view->execute;
            $your_variable = $result->result;
            $block['content'] = theme('videoblock', array('your_variable' => $your_variable));

You should poke around in the $result->result object to get to your content though.

Hope this helps

  • Fantastic, thank you very much this works perfectly! Sep 14, 2014 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.