From hook_save()
, I've updated the "pages" attribute of a block, adding a path to the list.
db_update('block')
->fields(array('pages' => $pages))
->condition('delta', $delta)
->execute();
I've used the database API, (maybe that's the problem?) instead of the block API, because I'm under the impression there is no support in Drupal 7 for this. (hook_block_configure()
I think is just for changes to default block configuration.)
The problem I'm having is that the update to the block pages attribute is not reflected, even after clearing caches, until I go to block edit form and click on Save.
There's actually one thing in core's block module function block_admin_configure_submit, and that is to pass the event along: module_invoke($form_state['values']['module'], 'block_save', $form_state['values']['delta'], $form_state['values']);
I'm not sure how go about structure $form_state['values']. Is there a way to do this with the block API?
With regard to Context, we're already using it; we could accomplish the same thing by writing to path to exclude to the context['condition']['path'] attribute, (prefixing the path ~ to indicated "exclude"). This might be a better approach for us, but still would like to see the block code working.
hook_block_info
,hook_block_save
,hook_block_configure
etc only provide the "base" to Drupal. These blocks you create won't get placed anywhere on the theme, until you configure the "instance". So through "Structure > Blocks" (or via different contrib module interfaces) you manage the "Instances" if you know what I mean. There's currently no easy way (a.k.a API) to manage the "instances" through code afaik