Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
Generally I find that if I am feeling the need to create a block with the PHP filter, its generally better to do the block as an implementation of hook_block. Keep code where code should be.
Comments
Where do you have that
Where do you have that statement?
in the block body field of
in the block body field of block configure like /admin/build/block/configure/block/9
Pretty sure $block isn't available in that context
I could be wrong, but the PHP snippit you put into the block body won't have access to the $block variable that your expecting to have.
Then is there any way to get
Then is there any way to get the block ID/title I want in this case?
Custom Block Module
Create a custom block module by creating a custom module and implementing hook_block
http://api.drupal.org/api/function/hook_block/6
You'll want to implement $op = 'list' and $op = 'view' at least. Check out the block_example module and follow that:
http://api.drupal.org/api/drupal/developer--examples--block_example--blo...
Generally I find that if I am feeling the need to create a block with the PHP filter, its generally better to do the block as an implementation of hook_block. Keep code where code should be.
Matt