Closed (fixed)
Project:
Context Block Cache Alter
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
3 May 2011 at 16:20 UTC
Updated:
8 May 2011 at 12:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
nedjoLike context_layouts, context_blockcache_alter uses hook_context_registry_alter() to alter the block reaction plugin used. They can't both take over the block reaction.
It would be feasible though - and quite simple - to write a second version of the context_blockcache_alter plugin based on the context_layouts one and then use that if module_exists('context_layouts'). I'd welcome a patch.
Comment #2
bastnic commentedThanks nedjo, i will see swhat I can do.
Comment #3
nedjoGreat. To start, compare context_blockcache_alter_reaction_block::build_block() with context_reaction_block::build_block(). I added inline comments where I changed lines.
Comment #4
nedjoPartial patch attached. Your remaining work would be to write the context_layouts_blockcache_alter_reaction_block.inc file and add it to the plugins folder, following the approach in context_blockcache_alter_reaction_block.inc but basing your code on the build_block method in context_layouts.
Comment #5
bastnic commentedThanks fot this partial patch, I was looking in this direction.
It seems that context_layouts_reaction_block inherit of context_reaction_block withour overriding build_block. So I just have to report your build_blocck in a class context_blockcache_alter_reaction_block which inherits context_layouts_reaction_block. Am I wright?
Comment #6
nedjoHmm, looks okay, though it would be nice if we could avoid repeating code.
Need to check if context_layouts has a weight. If not, presumably will need to mess with module weights in hook_install() to ensure that context_blockcache_alter has a higher weight than context_layouts so that it will claim the block reaction after context_layouts does.
Comment #7
bastnic commentedYep, sorry, my project was so big it was difficult to reaally test it. I created a simple drupal site with just context_layouts and 2 differents template for two differents layout to easily make the difference.
This patch seems fully functional.
Comment #8
nedjoThanks bastnic, looks great. I've assigned you as a maintainer of the project. Suggestions before you commit this:
1. Rather than setting a relative weight for the module, I'm thinking it's best to hard code it at e.g. 5, so it's predictable by other modules trying to override it.
2. To avoid having to load it on every page, you could pull the _context_blockcache_alter_build_block() function into an include file and load as needed with module_load_include().
3. Please add PHP doc code comment for the hook_install() function (even though it's just "Implementation of hook_install().").
Thanks!
Comment #9
bastnic commentedThanks!
New version of the patch, with all your suggestions applied.
I suggest you (we?) un-sandbox it after the commit, make it an official module. Agreed ?
Comment #10
nedjoNice, thanks, pls go ahead and commit.
Re "unsandboxing", I don't have the availability to maintain this. Do you want to be the maintainer? If so, we can assign it to you and you can promote it to a full project.
Comment #11
bastnic commentedThanks, commited in your sandbox.