Hi there,

I have a custom home page, it's mostly static content. On one spot, I'd like to place a "last 5 entries" section. I have the view built already and am using it as a block in my sidebar, but the sidebar does not appear on the home page.

There really is no region to place a block on the home page, and even if there was, I'd need much more control than just popping it into a region.

Is there some way to make a call to the block directly so I can place it exactly where I want on my static page?

Comments

tdellaringa’s picture

Ok, I found this:

http://scratch.drupal.org/node/26502

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

This doesn't work though, I get nothing rendered (Recent_Articles is the name of my block). I have no idea what $delta means, possibly that number is wrong?

adolg’s picture

On my website, I have only one block that I added, and it looks to have delta = 1 (in the db and also in URL on Administer Blocks page).

Also, I wonder if block has to be enabled for that? but then it would be placed into one of the regions, wouldn't it...

tdellaringa’s picture

I have tried putting 1 and 2 in there, but to no avail...still nothing...

adolg’s picture

But what is in 'delta' column in your 'blocks' table? You need to find your block there. Or look at the end of 'configure' URL on your Administer Blocks page.

tdellaringa’s picture

Ok, looking on the configure URL - there is no number. I'm guessing because this block was created using the views module? Does it not work with those?

Edit: Looking at the blocks table --

Edit views Recent_Articles abac 1 0 left...

In the Delta column is "Recent_Articles" - many blocks have names, not numbers for the Delta...

ruggerit’s picture

I had the same problem; this was the solution that I used:

http://drupal.org/node/99721

tdellaringa’s picture

Thank you ruggerit for pointing that out. I found a solution, which admittedly I don't quite understand, but it works so I won't complain. This is what I did:

$view = views_get_view('Recent_Articles');
print views_build_view('block', $view, array(), false, 5);

This lists out the last 5 articles in block form.