Hello,

I'm using your module in order to use blocks and menus in different parts of my site.
Unfortunately, I have a problem: when I create a menu and I want to reference it, it does not appear in the autocomplete list.
I have to go on the page list block, and only after that, the menu is referenced in the autocompletion.

Is there a solution to this problem?

Thank you,

Laura

Comments

lesprit’s picture

Assigned: lesprit » Unassigned
bkonetzny’s picture

This is true for 7.x-1.13 as well. I created new Mini-Panels and they don't show up in the Blockreference dropdown field. Only after visiting admin/structure/block or manually calling block_flush_caches(), the new blocks show up in the dropdown.

rudiedirkx’s picture

It's not really a problem, is it? Rehashing all blocks is expensive and you don't change it a lot, so rehashing (flushing) every time you load the dropdown would be unnecessarily slow.

Going to the blocks admin page is acceptable, isn't it?

rudiedirkx’s picture

Title: Menus not showing up in the autocomplete » Menus not showing up in the autocomplete until blocks are rehashed
Status: Active » Closed (works as designed)
bkonetzny’s picture

The problem is, that the user in question is not allowed to access the blocks admin page, as the user is not a site builder. Leaving the user with no option to refresh the blocks. :(

rudiedirkx’s picture

Title: Menus not showing up in the autocomplete until blocks are rehashed » New blocks (eg Nodeblocks) don't show up in the blocks list until they're rehashed by an admin
Category: bug » feature
Status: Closed (works as designed) » Active

But a user can't make menus, can they? The users that can create new blocks, probably can access the block admin page.

You do have a point though. Nodeblocks can made by low-access users that can't rehash blocks...

So... that's not closed... and now the solution... Any ideas? I don't want to rehash blocks every page that contains a blockreference field.

ccshannon’s picture

I ran into the same problem and yes, I added a cache clear onto the nodeapi insert/update ops of any nodeblock type. It makes the creating/saving of nodeblocks take a lonnnggggg time, but it does allow editors to immediately see nodeblocks in block reference lists.

I took this from admin_menu Flush Cache > Cache tables ... you could play with the $core array to see if fewer tables can be flushed to achieve the same result. So, this code might be a sledgehammer to a fly, but it will at least make the flush automatic. Just make sure to only run it if the node being saved is your Nodeblock type(s).

        $core = array('cache', 'cache_block', 'cache_filter', 'cache_page');
        $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
        foreach ($cache_tables as $table) {
          cache_clear_all('*', $table, TRUE);
          // drupal_set_message('Cache cleared on table ' . $table);
        }
rudiedirkx’s picture

If you want to update the blocks list, all you have to do is _block_rehash(). Still expensive though. Rehashing after creating a nodeblock is a very reasonable option, but not before showing a blockreference field.

You could ask Johnny @ nodeblock to add that. Tell him Rudie sent you =)

atouchard’s picture

Why not rehash when a menu is created ? For updating block, block_flush_caches() is better.

rudiedirkx’s picture

Status: Active » Closed (works as designed)

Rehashing blocks when a menu is created isn't blockreference's responsibility. It's menu's. The same for nodes (nodeblock). Blockreference only takes blocks, it's not responsible, ever, for creating or updating those blocks.

If you really need a rehash after a menu is created, you can do that yourself in some tiny custom code.

atouchard’s picture

If you really need a rehash after a menu is created, you can do that yourself in some tiny custom code.

Yes, this is the good method.