By tdellaringa on
Hi folks,
Been trying for a couple days to use module_invoke() to place a block on a static page like so:
<?php
$block = module_invoke('Recent_Articles', 'block', 'view', 0);
print $block['content'];
?>
The problem is, the block created by my Recent_Articles view has a delta (the last argument in module_invoke) that is a *string*, not a number. It appears views write's the wrong type of data to the blocks table. The code above does not work. I assume if I can call the correct delta, I can get the module to work.
Has anyone successfully worked this out? Can you manually change the delta to a number without breaking the view (I'm guessing that is a bad idea...)
Comments
supposedly you just change
supposedly you just change number into 'string-delta'
$block = module_invoke('Recent_Articles', 'block', 'view', 'block-name-string');
First argument should be 'views'
Ive been banging my head to get this for 6.2
i got it to work using
$block = module_invoke('views', 'block', 'view', 'view_name-block_X');
where X is the views block delta (? i think that's what its called) and 'view_name' is the name of your view
so in the above case it would be:
$block = module_invoke(views', 'block', 'view', ''Recent_Articles-block_1');
(assuming that it is the first block defined in this view)
hope that helps someone.
This worked for me
There is only one block created in this view, so I didn't use anything like "-block_X". If I tried that, it didn't return any data. I simply used the View name as the last parameter.
Hope this helps.
______________________________________________________________________________________________________
mybesinformatik.com - Drupal website development
______________________________________________________________________________________________________
what about Drupal 6?
Hi, what about in Drupal 6?
I follow like what you suggest up there, but that doesn't work for me.
Do you have any other way?
Thanks in advance.
Regards,
Ardi
you gotta just go with it
you gotta just go with it even if you don't have multiple blocks and add the "-block_1"
If you expose form in block
If you expose form in block from views module, the block's page tell you what is your display name. Later you can return to the normal state of the view.
Thanks
Your syntax works perfectly for me in 6.12. Thanks very much.