Closed (works as designed)
Project:
Block reference
Version:
6.x-1.28
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Oct 2012 at 13:29 UTC
Updated:
2 Jun 2013 at 18:17 UTC
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
Comment #1
lesprit commentedComment #2
bkonetzny commentedThis 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.
Comment #3
rudiedirkx commentedIt'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?
Comment #4
rudiedirkx commentedComment #5
bkonetzny commentedThe 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. :(
Comment #6
rudiedirkx commentedBut 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.
Comment #7
ccshannon commentedI 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).
Comment #8
rudiedirkx commentedIf 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 =)
Comment #9
atouchard commentedWhy not rehash when a menu is created ? For updating block, block_flush_caches() is better.
Comment #10
rudiedirkx commentedRehashing 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.
Comment #11
atouchard commentedYes, this is the good method.