3

I'm building a module that defines several blocks and provides custom options for those blocks via hook_block_configure(). Two of these blocks were built from scratch using hook_block_info() and their configuration options defined in hook_block_configure() display as intended. In other words, if you navigate to Structure > Blocks and click configure for either of these two blocks, the custom configuration options are displayed as intended.

The third block is a Views block, defined by hook_views_api() and hook_views_default_views(), and the hook_block_configure() hook doesn't trigger at all for this block. Navigating to Structure > Blocks and clicking on configure for this block just shows the default block configuration options.

What I would like to know is how to add custom configuration options for this Views block or a similar solution. Is there any way to register this block so that it will also listen in on the hook_block_configure() hook? Or is there maybe a different hook that would allow me to accomplish my goal? My Google-fu has yielded nothing.

1

To "add fields to the block configure pages for these two blocks" (as in your question), you should look at the Bean module as a possible alternative to answer this question. Here is a quote about its project page:

Think of a Bean as a method to provide new types (compared to node this would be a content type) which then provides an add content interface to create as many blocks as you require (see screenshot below). The bean content can then be placed around the site just like any other block.

The video tutorial Drupal Bean module tutorial - using Bean Admin UI provides a great introduction to really understand the power of this module, and the kind of things you can do with it (by only using site building techniques, no custom coding involved). It also shows how the Bean module transforms Drupal blocks into fieldable entities.

PS: this is a D7 module, integrated in core in D8 ...

  • Thanks Pierre I never had read about the inclusion of Bean in D8, this is a great notice. – Adrian Cid Almaguer Dec 18 '15 at 15:55
  • To be honest, I only noticed that myself just recently. So if you've never used it (or seen it), hurry and start eperimenting with the D7 version already. Myself I first discovered it when deep-diving into the forena module, which basically allows creating blocks (using BEAN) that contain (tiny) "reports". Think of dashboards and things like that for this specific usecase ... The video tutorial in my answer will be sufficient to understand the power of thos BEAN module ... – Pierre.Vriens Dec 18 '15 at 15:59
  • I used the Bean module in one or two project, thanks for the info – Adrian Cid Almaguer Dec 18 '15 at 16:01
  • @Pierre.Vriens, I appreciate your input with this module, but it doesn't quite accomplish what I need. I've edited my question to (hopefully) make my needs more clear. – Beau Townsend Dec 18 '15 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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