Postponed
Project:
Block reference
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Apr 2014 at 15:01 UTC
Updated:
3 Jun 2018 at 23:38 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mstef commentedHere's a stab at it..
Comment #2
rudiedirkx commentedHa, good point. I've never used that one, so I forgot about that one. Same bug in 2.x.
Is
$theme_keythe right theme? It should be the front-end theme, not the admin theme. The Drupal blocks table is weird. It doesn't work like that in 2.x anymore.I'll check it out later.
Comment #3
mstef commentedI was thinking about that.. Maybe use variable_get('theme_default', '')?
Comment #4
rudiedirkx commentedThat's a way. Maybe
$theme_keyis smart. There's alsoglobal $theme, which is also a string, so I don't know which one's better. I don't know the difference.Which theme shouldn't be important at all. Blocks don't work like that. All blocks are available in all themes. 1.x is weird. You should try out 2.x, which has cleaned up a lot. (Still this bug though, but with a much easier fix in
_blockreference_find_blocks().)Comment #5
rudiedirkx commentedWtf happened to the preview button!? That was a useful button!
Comment #6
rudiedirkx commentedActually, I might've changed my mind...
_block_rehash()alters the block list when it's fetched from the db. I don't touch the db. (1.x does, 2.x doesn't.)What are you trying to do in this block info alter? The only thing you can do (in 2.x at least) is change the admin label (in
$block['info']).The original purpose of the info alter isn't reached with 2.x (or 1.x I think), because all flags (cache, region etc) are ignored, except 'info'.
I rather not add it. Thoughts?
Comment #7
mstef commentedI change 'info' in certain blocks under certain conditions that I want replicated in the autocomplete results for blockreference fields. Like I said, I can probably do the same thing using the custom hooks from this module, but it seems weird to duplicate code and to ignore a core hook that is also supposed to do the same thing.
Blocks have different settings per-theme, which is why the theme is passed in along with that hook. $theme_key is the current active theme on that request. I would think using variable_get() would be a better parameter to use, since it's the default theme.
I would jump to 2.x but this is already being used on the project and I don't want to migrate at this point.
Comment #8
rudiedirkx commented2.x has a full update path =) (Be careful of contrib modules using the Blockreference api though.)
You can choose and I'll do it like that in 2.x. No 'new features' in 1.x.
1. No block info alter, so autocomplete (and label and sorting etc) altering happens in blockreference hooks.
2. Block info alter per block providing module, so your block info alter implementation function is called several times, not once. (If you've configured only Views and Nodeblock to provide blocks, the function is called twice.)
Whatever you want =) Only real bug fixes in 1.x.
Comment #9
mstef commentedAlright, I understand. Well I did my part. You can choose how you want to handle it from here. I'll migrate to 2.x when I can - but for now, I'll be on 1.x.
Comment #10
mstef commentedYour custom hooks to alter are actually pretty useless without the other info from hook_block_info().
For example, in my hook_block_info_alter(), I change the titles of Menu blocks. There is no direct way for me to know which blocks are from menu via your hooks, since only bid and title are passed in.
Comment #11
rudiedirkx commentedYes, 1.x sucks.
You should link to the patch in #1 in your build file or PATCHES.txt (however you organize that) and just patch your version. There won't be a new 1.x release for a long time, probably, so shouldn't be any trouble.
2.x should pass in everything from block_info into the custom block list alters. If not, let me know soon, so I don't have to break backward compatibility before 2.0.
Comment #12
mstef commentedOh alright. I didn't know that. Thanks.
If you do ever decide to use my patch for anything, the variable names in the last two foreachs should be changed from $bids and $bid to $deltas and $delta.
Comment #13
mstef commentedUpdated patch, just in case someone finds this issue and uses it. I added a line to remove blocks that are no longer available via hook_block_info() (ie, an old block stuck in the DB).
Comment #14
rudiedirkx commentedComment #15
mstef commentedThe validation on the field messes up if the title of the block is altered..
Might need to remove this or do it differently..
Comment #16
mstef commentedThis removes that validation. I can't see a reason why it's needed.
Comment #17
mstef commentedLooks like blockreference_autocomplete_value() needs to be fixed as well..
Comment #18
pifagor commentedthe patch is outdated. Can you upgrade it?
Comment #19
pifagor commentedComment #20
alex_optimI don't see a need for working with this patch. Because the module is very changed and has another logic.
This patch is deprecated.
Now module working good. If is some problems with the module work I propose to create a new issue for current the module version.
Comment #21
pifagor commented