Hi nedjo,

I'm (very) interested to use this module, but I've a hug use of context_layouts.
A quick try with both context_layouts and your module activated don't seems to break the site. What is the reason of the "requirement error" ?

Thanks you very much in advance,

Comments

nedjo’s picture

Like 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.

bastnic’s picture

Thanks nedjo, i will see swhat I can do.

nedjo’s picture

Great. To start, compare context_blockcache_alter_reaction_block::build_block() with context_reaction_block::build_block(). I added inline comments where I changed lines.

nedjo’s picture

Partial 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.

bastnic’s picture

Thanks 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?

nedjo’s picture

Hmm, 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.

bastnic’s picture

Yep, 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.

nedjo’s picture

Thanks 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!

bastnic’s picture

Thanks!

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 ?

nedjo’s picture

Status: Active » Reviewed & tested by the community

Nice, 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.

bastnic’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Thanks, commited in your sandbox.