From bbbcbf9ac92f03dfd41c706eea0fcfb9c78ac7e4 Mon Sep 17 00:00:00 2001
From: Mark Carver <mark.carver@me.com>
Date: Fri, 11 May 2012 13:16:09 -0500
Subject: [PATCH] Allow DS to render block templates with inherited contextual
 links.

---
 ds.module |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ds.module b/ds.module
index eab0958..129e250 100644
--- a/ds.module
+++ b/ds.module
@@ -1136,6 +1136,10 @@ function ds_render_block_field($field) {
 
   list($module, $delta) = explode('|', $field['properties']['block']);
   $block = module_invoke($module, 'block_view', $delta);
+  $contextual_links = array();
+  if (is_array($block['content']) && isset($block['content']['#contextual_links'])) {
+    $contextual_links = $block['content']['#contextual_links'];
+  }
   if (isset($block['content']) && is_array($block['content'])) {
     $block['content'] = drupal_render($block['content']);
   }
@@ -1186,7 +1190,7 @@ function ds_render_block_field($field) {
         $elements = array('elements' => array('#block' => $block, '#children' => $block->content));
         // Add contextual links
         if (module_exists('contextual') && user_access('access contextual links')) {
-          $elements['elements'] += array('#contextual_links' => array('block' => array('admin/structure/block/manage', array($block->module, $block->delta))));
+          $elements['elements'] += array('#contextual_links' => array_merge($contextual_links, array('block' => array('admin/structure/block/manage', array($block->module, $block->delta)))));
         }
         return theme('block', $elements);
         break;
-- 
1.7.10

