0

Using Context, can I move a node's menu to a different region?

Or more specifically, from inside hook_context_page_reaction(), can I get access to the page's render array to move items between regions?

I'm working with this below.

/**
 * Implements hook_context_page_reaction().
 */
function context_movemenu_context_page_reaction()
{

    $node = node_load(menu_get_object()->nid);
    if ($plugin = context_get_plugin('reaction', 'context_movemenu')) {
         $plugin->execute();
    }
}

and using this execute() method. I'm just dumping all incoming args to see what I can send over.

function execute() {
   dpm(func_get_args());
}

Am I approaching this from the wrong location? Ideally, this sites has most of it's configuration in context. The site owner likes that workflow.

1 Answer 1

1

You could place all blocks in template_preprocess_page with

$variables['page'][$region_key] = array();
$variables['page'][$region_key][]['#markup'] = $region_content;

Seeing your edit, you can check for the plugins blocks like this

$context_content_bottom = array();
  $blocks_content_bottom = array();

  // Blocks that are assigned to the region using Context
  if ($plugin = context_get_plugin('reaction', 'block')) {
    $context_content_bottom = $plugin->block_get_blocks_by_region('content_bottom');
  }

  // Blocks that are assigned to the region using the blocks interface
  if ($blocks = block_get_blocks_by_region('content_bottom')) {
    $blocks_content_bottom = $blocks;
  }

  // Merge them together
  $vars['region']['content_bottom'] = array_merge($context_content_bottom, $blocks_content_bottom);

Taken from here

but why not do it in the UI ?? just place the block several times under opposed conditions

1
  • Why not the UI!! So I'm having a dumb day. I got lost in the rabbit hole of this. Thank you for pulling me back up. Right answer: The UI! Upvote.
    – Rick
    Commented Apr 5, 2016 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.