0

In a template file I am using this code

$blocks= block_get_blocks_by_region('revel_card_dashboard');

To grab blocks for a region to render at specific parts of the template. This is causing the regions to be created twice.

Checking stack traces the first time the blocks are created is by drupal core.

 2 => 
  array (
    'file' => 'C:\\xampp\\htdocs\\revel\\html\\includes\\module.inc',
    'line' => 799,
    'function' => 'call_user_func_array',
  ),
  3 => 
  array (
    'file' => 'C:\\xampp\\htdocs\\revel\\html\\modules\\block\\block.module',
    'line' => 854,
    'function' => 'module_invoke',
  ),
  4 => 
  array (
    'file' => 'C:\\xampp\\htdocs\\revel\\html\\modules\\block\\block.module',
    'line' => 674,
    'function' => '_block_render_blocks',
  ),
  5 => 
  array (
    'file' => 'C:\\xampp\\htdocs\\revel\\html\\modules\\block\\block.module',
    'line' => 318,
    'function' => 'block_list',
  ),
  6 => 
  array (
    'file' => 'C:\\xampp\\htdocs\\revel\\html\\modules\\block\\block.module',
    'line' => 268,
    'function' => 'block_get_blocks_by_region',
  ),
  7 => 
  array (
    'file' => 'C:\\xampp\\htdocs\\revel\\html\\includes\\common.inc',
    'line' => 5616,
    'function' => 'block_page_build',
  ),
  8 => 
  array (
    'file' => 'C:\\xampp\\htdocs\\revel\\html\\includes\\common.inc',
    'line' => 2583,
    'function' => 'drupal_render_page',
  ),
  9 => 
  array (
    'file' => 'C:\\xampp\\htdocs\\revel\\html\\includes\\common.inc',
    'line' => 2471,
    'function' => 'drupal_deliver_html_page',
  ),
  10 => 
  array (
    'file' => 'C:\\xampp\\htdocs\\revel\\html\\includes\\menu.inc',
    'line' => 531,
    'function' => 'drupal_deliver_page',
  ),
  11 => 
  array (
    'file' => 'C:\\xampp\\htdocs\\revel\\html\\index.php',
    'line' => 21,
    'function' => 'menu_execute_active_handler',

How can I grab the already created blocks instead of creating them a second time as the call up top seems to do?

Clarification: I do not want to simply cache the block because its important to update the block when the user revisits the page, but there is no point in updating it with time expensive methods twice a page view.

1
  • 1
    the blocks should already be in $page['revel_card_dashboard'] if you are asking about a page template.
    – Jimajamma
    Commented Mar 9, 2013 at 1:02

1 Answer 1

0
$blocks = $page['revel_card_dashboard'];

This line of code grabbed the blocks that had already been created by drupal's original passthrough.

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.